waltermilner

Untitled

Oct 21st, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. public class Test {
  2.     Test m;
  3.     String id;
  4.     Test(String s)
  5.     {
  6.       id=s;
  7.     }
  8.     void show()
  9.     {
  10.     System.out.println(id);
  11.     }
  12.     public static void main(String args[])
  13.     {
  14.     Test m1=new Test("Original m1");
  15.     Test m2=new Test("Orginal m2");
  16.     Test m3=new Test("Orginal m3");
  17.     m1.m=m2;
  18.     m2.m=m3;
  19.     m3.m=m1;
  20.     m1=null;
  21.     m2=null;
  22.     m3.show(); // original m3
  23.     m3.m.show(); // original m1
  24.     m3.m.m.show(); // orginal m2
  25.  
  26.  
  27.     }
  28.    
  29. }
Advertisement
Add Comment
Please, Sign In to add comment