In Java, primitive types are the basic data types that store simple values. They are not objects and are predefined in Java.
Primitive Data Types:
byte
: 1 byte, range: -128 to 127short
: 2 bytes, range: -32,768 to 32,767int
: 4 bytes, range: -2^31 to 2^31-1long
: 8 bytes, range: -2^63 to 2^63-1float
: 4 bytes, single-precision floating-pointdouble
: 8 bytes, double-precision floating-pointchar
: 2 bytes, represents a single Unicode characterboolean
: 1 byte, represents true or false
Example:
int num = 10;
double price = 99.99;
char grade = 'A';
boolean isValid = true;