title: Remove odd int node from linked list in Java
body: <p>I am calling this method on a Linked List that contains 5 nodes with int data &lt;4, 3 ,2 ,1 ,5>  <br>I want to remove odd ints and return &lt;4, 2>
  <br>I ran in main method   mylist.removeOdds
  It seems to be working properly but never deletes (assigns the previous node to the current next) 
  <br><strong><em>output</em></strong> <br>This output keeps going until i terminate
  <br>while condition loop entered
  <br>current element 3 previous element4
  <br>if condition met 
  <br>current element 3 previous element4
  <br>if condition met 
  <br>current element 3 previous element4
  <br>if condition met </p>
  
  <pre><code>Public void removeOdds() {
      Node current = head;
      Node previous=null;
      while ((current.getNext()) != null) {
          if (head == null) {
              System.out.println("The list is empty");
          } else {
              while (current != null &amp;&amp; (current.getElement()) % 2 != 1) {
                  previous = current;
                  current = current.getNext();
                  System.out.println("while condition loop entered");
                  System.out.println("current element " + current.getElement()+" previous element "+ previous.getElement());
              }
              if ((current.getElement()) % 2 == 1) {
                   System.out.println("if condition met ");
                  previous.setNext(current.getNext());
                  System.out.println("current element " + current.getElement()+" previous element "+ previous.getElement());
  
              } 
          }
      } 
  </code></pre>