Saw this question somewhere, and it makes me confused about the gc concept. So when it comes to line
s2 = null;
Which object is eligible for gc? I think s1 should be the eligible one. What do you think?
Following are the code. Please forgive me about any issue of the format as I'm using mobile.
class Student {
String name;
int age;
}
And
public class Test {
public static void main(String [] args){
Student s1 = new Student();
Student s2 = new Student();
Student s3 = new Student();
s1 = s3;
s3 = s2;
s2 = null;
}
}