title: traversing through a linked list in java
body: <p>I am writing an insert method for a linked list, and found one thing hard to understand. It works when traversing using this code: </p>
  
  <pre><code>class Node {
  int data;
  Node next;
  Node(int d) {
         data = d;
         next = null;
      }
  }
  
  public static  Node insert(Node head,int data) {
      Node conductor = head;
      if(conductor == null){
          head = new Node(data);
      }
      else{
         while(conductor.next != null){
             conductor = conductor.next;
         }
         conductor.next = new Node(data);
      }
      return head;
  }
  </code></pre>
  
  <p>but if I change the while loop to :</p>
  
  <pre><code>       while(conductor != null){
             conductor = conductor.next;
         }
         conductor = new Node(data);
  </code></pre>
  
  <p>It doesn't work. And I don't understand what the difference is.
  Can anyone help please?</p>