
Interesting, I wonder when that changed? I'm fairly sure that never used to be the case. I don't think it's something that you should rely on, especially since the VM spec says the following: "Although the Java virtual machine defines a boolean type, it only provides very limited support for it. There are no Java virtual machine instructions solely dedicated to operations on boolean values. Instead, expressions in the Java programming language that operate on boolean values are compiled to use values of the Java virtual machine int data type. The Java virtual machine does directly support boolean arrays. Its newarray instruction enables creation of boolean arrays. Arrays of type boolean are accessed and modified using the byte array instructions baload and bastore.2 The Java virtual machine encodes boolean array components using 1 to represent true and 0 to represent false. Where Java programming language boolean values are mapped by compilers to values of Java virtual machine type int, the compilers must use the same encoding." (source: http://java.sun.com/docs/books/jvms/second_edition/html/Overview.doc.html#22...)
As the object sizes are rounded to multiples of 8, it looks like a case of buy one, and get 7 for free!
MB> Yes, just tried that and the same amount of memory is used for 1 MB> boolean and 8 booleans. MB> MB> I attach the test program I am using (snarfed from the web with MB> extra booleans added by me). MB> MB> Cheers, MB> MB> Mark MB>