Java Learning primitive

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:

  1. byte: 1 byte, range: -128 to 127
  2. short: 2 bytes, range: -32,768 to 32,767
  3. int: 4 bytes, range: -2^31 to 2^31-1
  4. long: 8 bytes, range: -2^63 to 2^63-1
  5. float: 4 bytes, single-precision floating-point
  6. double: 8 bytes, double-precision floating-point
  7. char: 2 bytes, represents a single Unicode character
  8. boolean: 1 byte, represents true or false

Example:

int num = 10;
double price = 99.99;
char grade = 'A';
boolean isValid = true;