title: Changing variable value of linked list node in Java.
body: <p>In the code below, how come when I change the node variable two to null, the first node variable one still has a next value of 2?</p>
  
  <pre><code> public static void main(String[] args) {
      Node one = new Node(1);
      Node two = new Node(2);
      one.next = two;
  
      System.out.println(one.val + ", " + one.next.val); //1, 2
      two = null; //one.next.val is still 2
      System.out.println(one.val + ", " + one.next.val); //1 ,2
  }
  
  static class Node {
      int val;
      Node next;
      public Node(int val) {
      this.val = val;
      }
  }
  </code></pre>