Need Assistance?

support@tutorialshub.in

Variables, Data Types & Operators

Primitive vs Non-Primitive Data Types

ADVERTISEMENT
Java Free Lesson
5 min read
ADVERTISEMENT

Java has 8 Primitive Data Types built directly into the language for maximum speed and low memory usage, plus Non-Primitive (Reference) Types like String, Arrays, and Classes.

The 8 Primitive Types & Sizes

  • byte (1 byte): -128 to 127
  • short (2 bytes): -32,768 to 32,767
  • int (4 bytes): ~ -2.14B to 2.14B (default for whole numbers)
  • long (8 bytes): Large integers (suffix with L, e.g., 9000000000L)
  • float (4 bytes): Single-precision decimal (suffix with f, e.g., 3.14f)
  • double (8 bytes): Double-precision decimal (default for decimals)
  • char (2 bytes): Single Unicode character in single quotes ('A')
  • boolean (1 bit): true or false
ADVERTISEMENT
Hi, I'm Tuby! Here to help you