class Cardboard{
Short story = 200;
Cardboard go(Cardboard cb){
cb = null;
return cb;
}
public static void main(String args[]){
Cardboard c1 = new Cardboard();
Cardboard c2 = new Cardboard();
Cardboard c3 = c1.go(c2);
c1 = null;
}
}
After go() is executed c2 should be pointing towards null, as implied by the method.This reference of c2 is passed to c3 variable, which again is pointing to null only thus c2's object must be available for garbage collection.