根据官方文档的描述:
boolean: The boolean data type has only two possible values: true and false. Use this data type for simple flags that track true/false conditions. This data type represents one bit of information, but its “size” isn’t something that’s precisely defined.
翻译:
boolean:boolean数据类型只有两个可能的值:true和false。将此数据类型用于跟踪真/假条件的简单标志。此数据类型表示一位信息,但其“大小”不是精确定义的内容。
根据 Java 虚拟机规范,JVM 并没有任何供 boolean 值专用的字节码指令,Java 源代码中使用到的布尔值,在编译之后都使用 int 值来代替。此时boolean占4个字节。JVM 也支持 boolean 类型数组,其一般经过编译会被当作 byte 数组进行处理。此时boolean占1个字节。boolean具体占多少字节,还要看虚拟机是如何处理的。没有固定的大小。