title: How to write a contains method for linked lists using recursion? java
body: <p>I need to write a contains method using recursion, meaning finding whether 'element' exists in one of the nodes.</p>
  
  <pre><code>    public class SortedSetNode implements Set 
      {
          protected String value;
          protected SortedSetNode next;
      }
  
      public boolean contains(String el) {         
  
          if (next.getValue().equals(el))
          {
              return true;
          }
          else
          {
              next.contains(el);
          }
  
      }
  </code></pre>