I see size of boolean is not defined. Below are two statements I see at java primitive data size
not precisely defined
Further explanation says
boolean represents one bit of information, but its “size” isn’t something that’s precisely defined.
Question came to my mind was why boolean in java can’t be represented with 1 bit(or 1 byte if byte is minimum representation ) ?
But I see it has been already answered at https://stackoverflow.com/questions/1907318/why-is-javas-boolean-primitive-size-not-defined where it says
the JVM uses a 32-bit stack cell, used to hold local variables, method arguments, and expression values. Primitives that are smaller than 1 cell are padded out, primitives larger than 32 bits (long and double) take 2 cells
Does it mean even byte/char/short primitiva data types also take 32 bit though their size is defined as 8/16/16 bit ?
Also can we say boolean size will be 32 bit on 32 bit cpu and 64 bit on 64 bit cpu ?