Anuj Kumar
In Java how to get size of class and object?
4 Answer(s)      4 years and 9 months ago
Posted in : Java Beginners

In Java how to get size of class and object?

Advertisement
View Answers

December 23, 2010 at 3:19 PM


Hi Friend,

Try the following code:

public class FindSizeOfObject{
    public static void main(String[] args) throws Exception{

Runtime obj = Runtime.getRuntime();
System.out.println(obj.totalMemory() - obj.freeMemory()); 
    }
}

Thanks



December 24, 2010 at 11:06 AM


No buddy

I want to display the size of the class and its object.

lets take one example:

class A{



December 24, 2010 at 11:08 AM


No buddy

I want to display the size of the class and its object.

lets take one example:

class A{

private int x;

public static void main(String []args){

A a = new A();

}

}

I want to display size of the class and object a.

Kindly help it out.

Thanks



December 24, 2010 at 11:10 AM


please respond to it asap.