Can anybody explain to me how objects are stored and removed from heap memory of Java. I'm looking for more information than simply:
an
Objectwill removed when there is no reference
For example:
class Heap
{
    void add(int a, int b)
    {
        System.out.println(a+b);
    }
    public static void main(String ar[])
    {
        Heap obj=new Heap();
        obj.add(4,3);
        obj.add(5,5);
    }
}
Here how is obj and a, `bJ allocated in java memory. When will  it be removed  from memory by the JVM?
 
     
     
     
     
    