What are the condition which can cause an object to be garbage collected?
A Java object is ready to be garbage collected if there are no active references to the object. Let us say you declare an object of type ArrayList inside a for loop and process it. That object is local to the for loop and once the loop is executed there are no open references to the array list. Hence after the method is executed this object would be eligible to be garbage collected. The JVM garbage collector would search for such unused/unreferenced objects and clear them.