Primitive Data Types in Java
| Keyword | Description | Size/Format | Default Value | Extreme Values |
|---|---|---|---|---|
| (integers) | ||||
byte |
Byte-length integer (signed) | 8-bit two's complement | 0 | -128 to 127 |
short |
Short integer (signed) | 16-bit two's complement | 0 | -32768 to 32767 |
int |
Integer (signed) | 32-bit two's complement | 0 | -2147483648 to 2147483647 |
long |
Long integer (signed) | 64-bit two's complement | 0 | -9223372036854775808 to 9223372036854775807 |
| (real numbers) | ||||
float |
Single-precision floating point | 32-bit IEEE 754 | 0.0 | plus or minus
1.40239846E-45, to
plus or minus 3.40282347E+38 |
double |
Double-precision floating point | 64-bit IEEE 754 | 0.0 | plus or minus
4.94065645841246544E-324, to
plus or minus 1.79769313486231570E+308 |
| (other types) | ||||
char |
A single character | 16-bit Unicode character | \u0000 | \u0000 to \uFFFF |
boolean |
A boolean value (true
or false) |
true or false (1 bit) | false | NA |
Note: Default values DO NOT apply when data is local to a method and generated on the stack, in which case NO automatic initialization takes place. Default initialization occurs when data appears in the heap as part f an object.