fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Node{
  8. String data;
  9. Node otherNode;
  10. Node(String data){
  11. this.data=data;
  12. }
  13. Node getOtherNode(){
  14. return otherNode;
  15. }
  16. @Override
  17. public String toString(){
  18. return this.data;
  19. }
  20. }
  21.  
  22.  
  23. class Ideone
  24. {
  25.  
  26. public static void main (String[] args) throws java.lang.Exception
  27. {
  28.  
  29. Node first = new Node("FIRST");
  30. Node second = new Node("SECOND");
  31. first.otherNode = second;
  32. second.otherNode = first;
  33.  
  34. System.out.println(first.getOtherNode());
  35. }
  36. }
Success #stdin #stdout 0.09s 2184192KB
stdin
Standard input is empty
stdout
SECOND