wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes size of boolean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "size of boolean" Watch "size of boolean" New topic
Author

size of boolean

Shivangi Joshi
Greenhorn

Joined: Jun 01, 2007
Posts: 23
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.


thanks in advance

shivangi...
Nathan Leniz
Ranch Hand

Joined: Nov 26, 2006
Posts: 132
Here is a topic covering that question.

I found this on the sun forums.

"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".
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11152
    
  16

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: size of boolean
 
Similar Threads
Boolean Size
size of boolean
what is the size of boolean type
About boolean bit size
width of boolean