Home Answers Viewqa Java-Beginners In Java how to get size of class and object?

 
 


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

In Java how to get size of class and object?

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.









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.