NaiveSizeOf.java | Class | Sizeof For Java(tm)
Java(tm) has no sizeof() operator like C/C++.With uniform sizes for primitive data types,
and a different style of memory allocation, the need for sizeof() really isn't there.
And it's hard to define what sizeof() would mean anyway, given that an object may not
contain other objects, but only references to them.
But it's interesting to experiment with the 1.1 reflection feature and see whether a
method can be devised that will return useful information about object sizes.
The Sizeof class below tries to do this, for a passed-in data structure. |