Java determines the size of each primitive type. These sizes don’t change from one machine architecture to another as they do in most languages. This size invariance is one reason Java programs are portable.
|
Primitive type |
Size |
Minimum |
Maximum |
Wrapper type |
|
boolean |
— |
— |
— |
Boolean |
|
char |
16-bit |
Unicode 0 |
Unicode 216- 1 |
Character |
|
byte |
8-bit |
-128 |
+127 |
Byte |
|
short |
16-bit |
-215 |
+215—1 |
Short |
|
int |
32-bit |
-231 |
+231—1 |
Integer |
|
long |
64-bit |
-263 |
+263—1 |
Long |
|
float |
32-bit |
IEEE754 |
IEEE754 |
Float |
|
double |
64-bit |
IEEE754 |
IEEE754 |
Double |
|
void |
— |
— |
— |
Void |
All numeric types are signed, so don’t look for unsigned types.
所有的primitive数据类型都是有符号的,那么怎么表示无符号的4字节数呢?
本文详细介绍了Java中各种原始类型的大小、取值范围及其对应的包装类,并指出所有数值型原始类型均为有符号类型。

被折叠的 条评论
为什么被折叠?



