No, it is not a single bit in Java.
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.
2006-10-13 01:30:09
·
answer #1
·
answered by IT Pro 6
·
1⤊
0⤋
Interestingly, I don't think this is defined anywhere. While C++ has the need for a sizeof() call, Java does not. You piqued my curiosity, though, and I dug up the following link which seems to indicate a boolean is a single byte.
http://www.glenmccl.com/tip_038.htm
Good question, though. I hope somebody has a more definitive answer!
2006-10-13 02:30:42
·
answer #2
·
answered by Dr.Mr.Ed 5
·
0⤊
0⤋
size of boolean data type in java is single bit .ie. either 0 or 1
2006-10-13 01:28:19
·
answer #3
·
answered by smiley 1
·
0⤊
1⤋
I suspect that it occupies the smallest handleable space - a byte. Very few languages actually use a single bit to store bools, the reason being that if you do that, it means that every other variable after that has to be at a weird offset in memory. Memory is organised by the byte, so it makes sense to use a whole one.
Why not try this simple test - create a file of say 1024 bools, then see how big it is in bytes.
Rawlyn.
2006-10-13 02:40:09
·
answer #4
·
answered by Anonymous
·
0⤊
0⤋