In reference to : Calculate size of Object in Java
I tried to run this program and get the size of the object created
//main
while(true){
Integer x=new Integer(50);
System.out.println("HashCode of this object="+x.hashCode()+"
, with Size of "+ObjectSizeFetcher.getObjectSize(x));
i++;
}
The output -- NullPointerException is thrown when getObjectSize() is invoked.
new Integer() -->
should have created a new wrapper object. Instead it creates NPE. Why ?
java version "1.6.0_65" Apple OSX - 10.9.1 --Ignore Syntax errors