Java has eight built-in data types, referred to as the Java primitive types.
boolean
Type: true or false
Example:
boolean isJavaFun = true;
boolean isFishTasty = false;
System.out.println(isJavaFun); // Outputs true
System.out.println(isFishTasty); // Outputs false
byte
Type: 8-bit integral value
Example:
byte myNum = 100;
System.out.println(myNum);
short
Type: 16-bit integral value
Example:
short myNum = 5000;
System.out.println(myNum);
int
Type: 32-bit integral value
Example:
int myNum = 123;
System.out.println(myNum);
long
Type: 64-bit integral value 123L
Example:
long myNum = 123L;
System.out.println(myNum);
float
Type: 32-bit floating-point value 123.45f
Example:
float myNum = 123.45f;
System.out.println(myNum);
double
Type: 64-bit floating-point value
Example:
double myNum = 123.456d;
System.out.println(myNum);
char
Type: 16-bit Unicode value
Example:
char myChar = 'z';
System.out.println(myGrade);
A primitive is not an object in Java nor does it represent an object. A primitive is just a single value in memory, such as a number or character.