Variables and Data Types
Introduction to Variables
Variables store data values, and in Java, they must be declared with a specific data type.
Primitive Data Types in Java
Examples include int
, double
, char
, and boolean
. Each type serves a different purpose and uses different memory.
Non-Primitive Data Types
Arrays, strings, and classes are examples of non-primitive data types, which hold references rather than actual data.