Skip to main content

Java Data Types

Data TypeSizep/rValue
boolean11 bitp (Primitive)True or False
byte11 bytep128-128 to 127127
short22 bytesp32,768-32,768 to 32,76832,768
int44 bytesp2-2 billion to 22 billion
long88 bytesp9-9 quintillion to 99 quintillion
float44 bytespFractional number up to 676-7 digits [ 2.718281f2.718281f ]
double88 bytespFractional number up to 1515 digits [ 2.718281828459042.71828182845904 ]
char22 bytespSingle character/letter/ASCII value [ 'a' ]
stringvariesr (Reference)A sequence of characters ["Carpe diem"]

Primitive vs. Reference Data Types

PrimitiveReference
Eight (8) typesUnlimited and user defined
Stores dataStores and address
Holds only 1 valueHolds more than one value
Needs less memoryNeeds more memory
FasterSlower