Data TypeSizePrimitive/ReferenceValue
boolean1 bitprimitivetrue or false
byte1 byteprimitive-128 to 127
short2 bytesprimitive-32,768 to 32,767
int4 bytesprimitive-2 billion to 2 billion
long8 bytesprimitive-9 quintillion to 9 quintillion
float4 bytesprimitivefractional number up to 6-7 digits (e.g., 3.141592f)
double8 bytesprimitivefractional number up to 15 digits (e.g., 3.141592653589793)
char2 bytesprimitivesingle character/letter/ASCII value (e.g., ‘f’)
Stringvariesreferencea sequence of characters (e.g., “Hello world!“)

Note

If u need to assign value to float data type u need to add f at end of the number, but not in double


Primitive vs Reference Data Types

Transclude of Drawing-2024-08-28-03.41.15.excalidraw