| Author |
boolean Variable Size?
|
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
Q) What is the size of boolean Variable in JAVA???
|
SCJP 6.0 96%
(Connecting the Dots ....)
|
 |
Jeanne Boyarsky
internet detective
Marshal
Joined: May 26, 2003
Posts: 26141
|
|
Sahil,
Welcome to JavaRanch!
A boolean is one bit since there are only two choices of value. Search "java primitive size" if you are looking for sizes of other types.
|
[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
|
 |
Muhammad Khojaye
Ranch Hand
Joined: Apr 12, 2009
Posts: 341
|
|
I found this quote from sun tutorial Primitive Data Types
This data type represents one bit of information, but its "size" isn't something that's precisely defined.
Please correct me, if i am wrong.
|
http://muhammadkhojaye.blogspot.com/
|
 |
Sahil Kapoor
Ranch Hand
Joined: Sep 12, 2009
Posts: 316
|
|
Thanks Jeanne Boyarsky !!!
@Muhammad Ali Khojaye
I think its JVM dependent feature, but since it represents only 1 bit of information , it should be of size 1-bit.
But may be JVM has to store something else in it .....So the size may vary i think.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32599
|
|
|
The tutorial is correct; the "size" of a boolean can vary from one implementation to another. It is only necessary to use 1 bit, but that leaves at least 7 bits in the byte which cannot be used. So it might be easier to use all 8 bits.
|
 |
 |
|
|
subject: boolean Variable Size?
|
|
|