Java Data Type Tutorial - Java Primitive Data Type








Java defines eight primitive types of data: byte, short, int, long, char, float, double, and boolean.

The primitive types are commonly referred to as simple types.

These can be put in four groups:

  • Integers - includes byte, short, int, and long, which are for whole-valued signed numbers.
  • Floating-point numbers - includes float and double, which represent numbers with fractional precision.
  • Characters - includes char, which represents symbols in a character set, like letters and numbers.
  • Boolean - This group includes boolean, which is a special type for representing true/false values.

You can use these types to construct arrays or your own class types.

The primitive types represent single values-not complex objects. Although Java is otherwise completely object-oriented, the primitive types are not.

The primitive types have an explicit range and mathematical behavior.





Strongly Typed

Java Is a Strongly Typed Language.

Every variable has a type, every expression has a type, and every type is strictly defined.

All assignments are checked for type compatibility.

There are no automatic coercions or conversions of conflicting types.

The Java compiler checks all expressions and parameters to ensure that the types are compatible.