Possible Duplicate:
Is there any sizeof-like method in Java?
Does Java have operator something like sizeof() in C?
Possible Duplicate:
Is there any sizeof-like method in Java?
Does Java have operator something like sizeof() in C?
The answer is no.
However there are some simple approaches to achieve that. Write your own sizeof method.
public static int sizeof(Class cl)
{
if (cl == Integer.class || cl == int.class) return 4;
if (cl == Character.class || cl == char.class) return 2;
//...
}
The size of the object will depend on the JVM implementation. There is the Java SizeOf project which handles all cases correctly.