Whit very simple example I want to ask you about garbage collection in Java. I have few object in one arrayList. In some point I want to remove one object from the arrayList and at the same time I want to destroy this object. How to do this? Please help!
Here is example:
class SomeClass{
    public SomeClass()
    {
    }
}
public class Test 
{
    public static void main(String[] args)  throws Throwable
    {
        SomeClass a = new SomeClass();
        SomeClass b = new SomeClass();
         ArrayList<SomeClass> arr = new ArrayList<SomeClass>();
          arr.add(a);
          arr.add(b);
          //this doesn't work
          SomeClass tmp =  arr.remove(0);
          tmp = null;
          /* I want to do something like this. I want to remove the object from arrayList
              and at the same time to clean this object. Something like this:
              arr.remove(0) = null;
          */
          System.out.println(a);
    }
}
 
     
     
     
    