Java has 8 primitive types and the can be put in four groups:

  • Integer
  • Floating-point numbers
  • Character
  • Boolean

These types can be used as-is to define variables in a method, define method parameters, or define attributes of a class.

Integer types

Java has four integer types: bytes, short, int and long. All of them are signed, that means they have negative and positive values.

The types differs in how much amount of memory they consume. But in practice you should not calculate the amount of used memory but choose the type according to the behavior what is needed. If we need to store day of the week when we should

Comments powered by CComment