Data Types and Their Size in Java

Spread the love

Java have two types of data types.

  1. Primitive Data Types

  2. User Defined Data Types

Java is statically typed and also a strongly typed language : because we have to declare the type of each variable and one variable cannot store value of other type of variable. But languages like PHP, Python are dynamically typed because their variable can take any type of variable and we don’t have to tell the type of value a variable will store.

Primitive Data Types :

  1. byte  – 1 Byte
  2. short – 2 Byte
  3. int – 4 Byte
  4. char – 2 Byte (Depends on encoding)
  5. float – 4 Byte
  6. double – 8 Byte
  7. Boolean – 1 Byte
  8. long (int java 8) – 8 Byte

More info on java Data types : Go Here and Here

Backup of above article : Go Here (1st) and Here(2nd)