In the recent summary, found that the size of the Boolean type is very tangled, and then looked at the Internet, and found that the views of the Internet are also different opinions.
With a question I downloaded the latest "The Java Virtual Machine specification" from the official website of Oracle, this is the seventh edition, the final revision date is 2012-7-27
This is explained in the JVM:
Although the Java Virtual machine defines a Boolean type,it only provides very limited for it. There are no Java Virtual machine instructions solely dedicated to operations on Boolean values. Instead, expressions in the Java programming language this operate on Boolean values are compiled to use values of the JAV A virtual machine int data type.
The Java virtual machine does directly support Boolean arrays. Its newarray instruction enables creation of Boolean arrays. Arrays of type Boolean are accessed and modified using the byte array instruction baload and Bastore.
In Oracle Java Virtual machine Implementation, Boolean arrays in the Java programming language are encoded as Java virtual Machine byte arrays, using 8 bits per boolean element.
The Java Virtual machine encodes Boolean array components using 1 to represent true and 0 to represent false. Where Java programming Language Boolean values are mapped by compilers to values of Java virtual machine type int, the CO Mpilers must use the same encoding.
One conclusion from the above explanation is that a single Boolean type variable is the type of int that is used at compile time. In the case of a Boolean array, each component in a Boolean array is compiled as a byte array at compile time, which is OK.
Personally think: A single Boolean type variable, Boolean B, which says B is four bytes like int, I don't think it's appropriate. When a Boolean type is compiled in the description above, the Boolean value is mapped to the compiler as an int, and there is no specific boolean-type instruction in the JVM. It should be that when a program reads a Boolean, it creates a space in the "data" area of the memory to hold true, or false.