title: Can't solve indexOf function for Doubly Linked list
body: <p>I have a function that I can't seem to figure out.</p>
  
  <p>Instructions:</p>
  
  <p>Returns the index of the first occurrence of the specified element in this list,
  or -1 if this list does not contain the element
  index is 0-based (i.e., the first 'real' node (after dummy header) is index 0).
  @param x the element to search for</p>
  
  <p>So, what's happening here is the function is passed in an Object, in my case a number.  IndexOf is supposed to go through the list of numbers and see if any match.  If it finds a match, it will return the INDEX of the object.  My issue is that it just returns whatever result is initialized to.  How can I make it so it returns the index?</p>
  
  <pre><code>public int indexOf(Object x)
  {
      Node current = head; 
      int result = 0;
      for(int i = 0; i &lt; elementCount; i++){
          if(x.equals(current.data)){
            result = i;
            return result;
          }
      }
      return result;
  }
  </code></pre>