File tree 1 file changed +10
-10
lines changed
1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -640,16 +640,16 @@ Java 中有 8 种基本数据类型,分别为:
640
640
641
641
这 8 种基本数据类型的默认值以及所占空间的大小如下:
642
642
643
- | 基本类型 | 位数 | 字节 | 默认值 |
644
- | : -------- | : -- - | : -- - | : ------ |
645
- | `byte ` | 8 | 1 | 0 |
646
- | `short ` | 16 | 2 | 0 |
647
- | `int ` | 32 | 4 | 0 |
648
- | `long ` | 64 | 8 | 0L |
649
- | `char ` | 16 | 2 | ' u0000' |
650
- | `float ` | 32 | 4 | 0f |
651
- | `double ` | 64 | 8 | 0d |
652
- | `boolean ` | 1 | | false |
643
+ | 基本类型 | 位数 | 字节 | 默认值 | 取值范围 |
644
+ | : -------- | : -- - | : -- - | : ------ | ------------------------------------------ |
645
+ | `byte ` | 8 | 1 | 0 | - 128 ~ 127 |
646
+ | `short ` | 16 | 2 | 0 | - 32768 ~ 32767 |
647
+ | `int ` | 32 | 4 | 0 | - 2147483648 ~ 2147483647 |
648
+ | `long ` | 64 | 8 | 0L | - 9223372036854775808 ~ 9223372036854775807 |
649
+ | `char ` | 16 | 2 | ' u0000' | 0 ~ 65535 |
650
+ | `float ` | 32 | 4 | 0f | 1.4E-45 ~ 3.4028235E38 |
651
+ | `double ` | 64 | 8 | 0d | 4.9E-324 ~ 1.7976931348623157E308 |
652
+ | `boolean ` | 1 | | false | true 、 false |
653
653
654
654
对于 `boolean `,官方文档未明确定义,它依赖于 JVM 厂商的具体实现。逻辑上理解是占用 1 位,但是实际中会考虑计算机高效存储因素。
655
655
You can’t perform that action at this time.
0 commit comments