This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
3. X x = new X(); //create one. x references to it 4. X x2 = m1(x); //create one in m1 method. x2 references to it 5. X x4 = new X(); //create one. x4 references 6. x2 = x4; //x2 references to x4's object. x2 originally referenced object can be GC.
Joined: May 10, 2006
Thanks 4 reply, Wise Owen u r saying, X x=new X();//creat one I think it creates two objects, then how one object eligible 4 garbage colln.
Plz clear it to me, I'm a bit confuse.
Thanks in advance.
Joined: Feb 02, 2006
How many instances of X are created from line 3 to 5? Can you explain why u think 2 objects 4 GC?