Primitive Types Cheatsheetsuggest change
Table showing size and values range of all primitive types:
data type | numeric representation | range of values | default value | —— | —— | —– | —– | boolean | n/a | false and true | false | byte | 8-bit signed | -27 to 27 - 1 | 0 | | | -128 to +127 | short | 16-bit signed | -215 to 215 - 1 | 0 | | | -32,768 to +32,767 int | 32-bit signed | -231 to 231 - 1 | 0 | | | -2,147,483,648 to +2,147,483,647 | long | 64-bit signed | -263 to 263 - 1 | 0L | | | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | float | 32-bit floating point | 1.401298464e-45 to 3.402823466e+38 (positive or negative) | 0.0F | double | 64-bit floating point | 4.94065645841246544e-324d to 1.79769313486231570e+308d (positive or negative) | 0.0D | char | 16-bit unsigned | 0 to 216 - 1 | 0 | | | 0 to 65,535 |
- The Java Language Specification mandates that signed integral types (
long) use binary twos-complement representation, and the floating point types use standard IEE 754 binary floating point representations.
- Java 8 and later provide methods to perform unsigned arithmetic operations on
long. While these methods allow a program to treat values of the respective types as unsigned, the types remain signed types.
- The smallest floating point shown above are subnormal; i.e. they have less precision than a normal value. The smallest normal numbers are 1.175494351e−38 and 2.2250738585072014e−308
charconventionally represents a Unicode / UTF-16 code unit.
- Although a
booleancontains just one bit of information, its size in memory varies depending on the Java Virtual Machine implementation (see boolean type).