You can implement Serializable in the class and then write an instance of
the class to a file. The size of the file will tell you how big the object
was when it was serialized. Keep in mind that this doesn't tell you the
maximum possible size. For instance, if you have Strings as state inside
your class, the size of them can vary greatly. Also keep in mind that any
objects stored inside the class (unless they're declared as transient) must
also implement Serializable.
See the javadocs for java.io.ObjectOutputStream.
"Luiz Antonio Gomes Picanço" <lu**@luizantonio.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hi all,
I want to determine the size of my class at runtime. In C i do this:
struct
{
int id;
char name[30];
} registry
void main()
{
int size = sizeof(registry);
}
How i can do this in Java ?