File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Boolean Size" Watch "Boolean Size" New topic
Author

Boolean Size

Abhishek Jain
Greenhorn

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: 1526
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