Java Fundamentals: Variables, Data Types & Operators 🧮

Intermediate

Java's foundation begins with understanding its basic building blocks: variables, data types, and operators.

Variables are containers for data. Java is statically typed, requiring you to declare a variable's data type before use.

Data Types in Java include primitive types like:

  • int for integers
  • double for floating-point numbers
  • char for characters
  • boolean for true/false values

and non-primitive types like String, Arrays, and user-defined objects.

Operators perform operations on variables and values, including arithmetic (+, -, *, /), relational (==, >, <), and logical (&&, ||) operators.

Example:

int age = 25;
double price = 19.99;
boolean isActive = true;
String name = "Alice";