Originally posted by Suhita Reddy:
Hi all,
after line 6 runs,how many objects r eligible for garbage collection?
1.public class X{
2.public static void main(String args[]){
3.X x=new X();
4.X x2=m1(x);
5.X x4=new X();
6.x2=x4;
7.doComplexStuff();
8.}
9.static X m1(X mx){
10.mx=new X();
11.return mx;
12.}
13.}
Only one and it is object created by m1 method (line 4)