Hi!,
Thank you Edward for a great analysis.
However, I have tried answering the
"size of a primitive" question with the help of byte code but I could not go too far.
Check this out..
<pre>
class ByteCode {
public static void main (String av[]) {
boolean abool=true;
byteabyte=1;
shortashort=2;
char achar='a';
intanint=3;
/*
longalong=5L;
float afloat=4.0f;
doubleabouble=6.0;
*/
}
}
</pre>
Gets you the byte code (this is a relevant fragment)
<pre>
Method void main(java.lang.String[])
0 iconst_1
1 istore_1
2 iconst_1
3 istore_2
4 iconst_2
5 istore_3
6 bipush 97
8 istore 4
10 iconst_3
11 istore 5
13 return
</pre>
Here the primitives of type
boolean, byte, short, integer
and even
char are being stored as ints in the
local variable array of the frame.
IMHO it is better to stick with what the specs say. I would
say boolean is of size one bit.
Thoes who are interested in this kind of stuff there is a great
article at
Java[tm] bytecode: Understanding bytecode makes you a better programmer Enjoy
BonGadi
[This message has been edited by bongadi (edited May 14, 2000).]
[This message has been edited by bongadi (edited May 14, 2000).]