• Post Reply Bookmark Topic Watch Topic
  • New Topic

About boolean data type  RSS feed

 
Sethu Raman
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all

Why is boolean data type is called as Virtual Machine Deppendent....?
I come across this line while learning for certification exam.
Could anyone give me a clear idea regarding this...
How the jvm manages the boolean data type.....


Thanks in advance

Regards,
Sethu
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll have to guess exactly what the context of that question is, but probably what is meant is that it's not specified how much memory a boolean uses - how much memory a boolean uses can be different on different underlying platforms or JVM implementations.

For example, Sun's JVM might use a 32-bit integer for storing booleans in the computer's memory, while HP's JVM might use an 8-bit integer or something else. (This is just an example I just made up, these are not how Sun's or HP's JVMs really work).

For your Java program it makes no difference. A boolean can be 'true' or 'false', and how exactly the JVM stores a boolean in memory doesn't make any difference in the way your Java program works.
 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another point of view....
Some people might like to say that an int 0 is false, while an in 1 is true

Others might like to say int 0 is false and -1 is true, or the other way (since branch-on-minus, branch-on-not-minus is a quick conditional branch in many micro-architectures).

Some might like to say that 0 is fals and any non-zero value is a true...

What Sun is saying is..... we don't care HOW you choose to do it internally but let there be a notion of true and false.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!