Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1.         public void merge(Node secondList) {
  2.             if (first == null)
  3.                 return;
  4.  
  5.             if (secondList.first == null)
  6.                 return;
  7.  
  8.             Node thisNodeReference = this.first;
  9.             Node secondNodeReference = secondList.first;
  10.             Node thisNextNodeReference, secondNextNodeReference;
  11.  
  12.             while (thisNodeReference != null && secondNodeReference != null) {
  13.  
  14.                 thisNextNodeReference = thisNodeReference.next;
  15.                 secondNextNodeReference = secondNodeReference.next;
  16.  
  17.                 thisNodeReference.next = secondNextNodeReference;
  18.                 thisNodeReference = thisNodeReference.next;
  19.                 thisNodeReference.next = thisNextNodeReference;
  20.  
  21.                 thisNodeReference = thisNextNodeReference;
  22.                 secondNodeReference = secondNextNodeReference;
  23.             }
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement