Java Primitive Data Types


0

There are 8 Primitive data types in Java, you can categorize them into 4 groups.

  1. Integer data types: byte, short, int & long
  2. Floating Data types: float, double
  3. Character Data types: char
  4. Boolean Data types: boolean
Data TypeSizeDefault ValueRange
byte8-bit0-128 to 127
short16-bit0-32,768 to 32,767
int32-bit0-2^31 to 2^31-1
long64-bit0L-2^63 to 2^63-1
float32-bit0.0f
double64-bit0.0d
booleanNA'\u0000'NA
char16-bitfalseNA

Following is a sample program with using all primitive datatypes