DEV Community

Anees Abdul
Anees Abdul

Posted on

Data Types in Java:

What is a Data Type:

  • It defines what kind of data a variable can store (numbers, text, true/false, etc.)

Types of Data Type:

  1. Primitive Data Type (Java’s built-in basic types like int, char, and boolean that store single values directly).
  2. Non Primitive Data Type (They store references (memory addresses) of objects, not the actual value).

1.1: Types of Primitive Data Types/Default Values/Size:

  1. byte - 0 - 1 byte
  2. short- 0 - 2 byte
  3. int - 0 - 4 byte
  4. float- 0.0- 4 byte
  5. long - 0 - 8 byte
  6. double-0.0 - 8 byte
  7. char - - 2 byte
  8. boolean- False - 1 byte

2. Types of Non primitive Data Types:

  1. String - stores text ""
  2. Array - stores multiple values of the same type.

Top comments (0)