title: Removing a node from a linked list using recursion java
body: <p>So i have a linked list that I want to be able to remove the first occurrence of a number,</p>
  
  <p>I'm trying to use recursion but sadly all I end up doing is being able to delete the head of the list and</p>
  
  <pre><code>public List remove(int num){
     if(value == num) {
         return next.remove(value);
     }else{
         next = next.remove(value);
         return this;
     }
  }
  </code></pre>
  
  <p>I know i need to return the new list, but how exactly do i either get rid of the node that I'm trying to avoid or is there a way to work around it, so it continues to the next nod.</p>
  
  <p>Edit. Update on the actual code.</p>
  
  <pre><code>class List{
    int value;  //value at this node 
    List next;  //reference to next object in list
    public List(int value, List next){
        this.value = value;
        this.next  = next;
    }
  }
  </code></pre>
  
  <p>I have three different classes, one for the empty list at the end of this, and a class declaring this method, and the actual list.</p>
  
  <pre><code>  public static List makeSample() {
          EmptyList e = new EmptyList();
          List l1 = new List(5, e);
          List l2 = new List(4, l1);
          List l3 = new List(3, l2);
          List l4 = new List(3, l3);
          List l5 = new List(2, l4);
          List l6 = new List(1, l5);
          return l6;
      }
  </code></pre>