What is the size of type boolean?

John Mitchell

At the language level, it doesn't matter. In fact, at the language level you can't actually know the size anyways so it's completely irrelevant. As a primitive type, it can only take on two possible values, true and false.

In terms of the JVM specification, Section 3.3.4 covers the issue. Basically, standalone booleans (i.e., booleans that aren't in a boolean-typed array) are compiled to use the "int" JVM data type. Boolean arrays are covered by the baload and bastore instructions which allow for byte-per-boolean representation or e.g., a packed storage representation.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact