|





| |
Java Primitive Types
| Type |
Used
to store |
Default |
Range |
Size |
| boolean |
true and false |
false |
true or false |
1 bit |
| char |
Unicode character |
\u0000 |
Unicode (not ASCII) |
16 bits |
| byte |
signed integers |
0 |
-128 to 127 |
8 bits |
| short |
signed integers |
0 |
-32,768 to 32,767 |
16 bits |
| int |
signed integers |
0 |
-2,147,483,648 to 2,147,483,647 |
32 bits |
| long |
signed integers |
0 |
-9,223,372,036,854,775,808 to
+9,223,372,036,854,775,807 |
64 bits |
| float |
floating point |
0.0 |
1.40129846432481707e-45 to
3.40282346638528860e+38 (positive or negative) |
32 bits |
| double |
floating point |
0.0 |
4.94065645841246544e-324d to
1.79769313486231570e+308d (positive or negative). |
64 bits |
Notes:
 | Strings are an object type, an instance of the class java.lang.String. They are not null
terminated and are not the same as an array of chars. |
 | Arrays are also objects. Multidimensional arrays are created via arrays of
arrays. |
 | Ideally, every type in Java would be a class and inherit Java's base
class - called Object - from which all Java classes are derived. However,
the overhead to do that for basic numeric types - integer, float, etc. -
would slow the processing significantly.
|
|