Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Test {
- Test m;
- String id;
- Test(String s)
- {
- id=s;
- }
- void show()
- {
- System.out.println(id);
- }
- public static void main(String args[])
- {
- Test m1=new Test("Original m1");
- Test m2=new Test("Orginal m2");
- Test m3=new Test("Orginal m3");
- m1.m=m2;
- m2.m=m3;
- m3.m=m1;
- m1=null;
- m2=null;
- m3.show(); // original m3
- m3.m.show(); // original m1
- m3.m.m.show(); // orginal m2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment