can anybody please tell me what is size of boolean.i have already searched on net,the results are so much confusing,some says 1 bit(as per JVM specification),some says 1 byte, and not applicable,and many more.so please let me know what is correct size of boolean.
"There is actually no boolean type. A Java expression that operates on boolean values is compiled to use the int data type to represent boolean variables. This means a boolean is usually a 32-bit variable. However arrays of booleans are treated as arrays of bytes, so booleans are 8 bits in an array" [ July 26, 2008: Message edited by: Nathan Leniz ]
The very existence of flamethrowers proves that at some time, some where, some place, someone once said to themselves "I'd really like to set those people on fire over there, but I just can't get close enough".
as I understand it - it's not defined, and it doesn't matter. the authors of the JVM are free to make it whatever size they want or need to for whatever reason. They often choose a size that is most efficient on the specific platform their jvm will run on.
but more importantly, it doesn't matter. you can't do any byte manipulation like you would in C, so you never need to count over say seven bytes in an array...
Why is it so important that you know?
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop