-
Primitive Data Types:
These are the most basic data types in Java and are predefined by the language. They directly store values. There are eight primitive data types:byte: 8-bit signed integer.
short: 16-bit signed integer.
int: 32-bit signed integer.
long: 64-bit signed integer.
float: 32-bit single-precision floating-point number.
double: 64-bit double-precision floating-point number.
boolean: Represents a logical value, either true or false.
char: 16-bit Unicode character. -
Non-Primitive (Reference) Data Types:
These data types are not predefined by the language and are created by the programmer (except for String). They store references (memory addresses) to objects rather than the actual values. Common non-primitive data types include:String: Represents a sequence of characters. Although it's part of the java.lang package and often treated specially, String is technically a class and thus a non-primitive type.
Arrays: Used to store multiple values of the same data type in a single variable.
Classes: User-defined blueprints for creating objects.
Interfaces: Blueprints of a class, defining a set of methods that a class must implement.
Top comments (0)