• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Boolean Size

 
Abhishek Jain
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Akhilesh Trivedi
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
boolean is not one bit it is platform dependent.
 
Manfred Klug
Ranch Hand
Posts: 377
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic