Object creation in java

We know that the class code along with method code is stored in “method area” of the JVM. When an object is created, the memory is allocated on ‘heap‘. After creation of an object, JVM produces a unique identifier number for the object from the memory address of the object. This reference number is called hashcode number. 

To know the hashcode number of an object, we can use hashcode() method of object class as shown here..

Employee el=new Employee();

System.out.println(e1.hashcode());

Advertisements