diff --git a/notes/3. 数组中重复的数字.md b/notes/3. 数组中重复的数字.md index d249e72b..cc86e3b0 100644 --- a/notes/3. 数组中重复的数字.md +++ b/notes/3. 数组中重复的数字.md @@ -49,7 +49,11 @@ private void swap(int[] nums, int i, int j) { nums[j] = t; } ``` - +**`补充:`** +(1)boolean不是占1位,计算机处理处理数据的最小单元是1字节,一般1位的话,其余7位会被0补齐。 +(2)在java虚拟机规范中,JVM没有用于操作boolean的字节码指令,在编译后用int的数据类型代替boolean,此时boolean占4字节。 +(3)boolean[]数组编译后会被byte[]数组代替,此时的boolean占1字节。 +总结:boolean单独存在占4字节,在boolean[]中占1字节。