This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Boolean Size Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boolean Size" Watch "Boolean Size" New topic

Boolean Size

Abhishek Jain

Joined: Sep 02, 2005
Posts: 26
Hello Ranchers,

Sorry but a silly question, m just wondering what is the size of boolean in Java, I goggled it and found someone saying 1,2,4 bytes but this made me thinking when we can store boolean in 1 bit than what is the reason for some extra memory..

waiting for your expert comments guys...

SCJP <br />SCWCD <br />SCBCD <br />SCEA Preparing
Akhilesh Trivedi
Ranch Hand

Joined: Jun 22, 2005
Posts: 1599
boolean is not one bit it is platform dependent.

Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Manfred Klug
Ranch Hand

Joined: Jun 04, 2007
Posts: 377
Originally posted by Abhishek Jain:
when we can store boolean in 1 bit than what is the reason for some extra memory
Performance. For example, it may be faster to read/write four bytes instead of one or two.
It is sorta covered in the JavaRanch Style Guide.
subject: Boolean Size
It's not a secret anymore!