To check if an element exists in the Stacked List
<p>I was supposed to code pop, push and contains for linkd List Stack. I did manage to get pop and push to work but had no luck with contains. For some strange reason it always returns false even if the thing is in the list, could any one help.</p>

<hr>

<p>public class LinkedListStack implements Stack {</p>

<pre><code>IntNode&lt;E&gt; front;
IntNode&lt;E&gt; current = front, previous;
private int size =0;


public void push(Object o) {
    IntNode&lt;E&gt; temp = new IntNode&lt;E&gt;((E) o);            
    if(current==null &amp;&amp; size==0){
        current = temp;
        front = temp;
    }else{
        current.link = temp;
        previous = current;
        current = temp;
    }
    size++;
}


public E pop() {        
    IntNode&lt;E&gt; pop = current;
    current = previous;
    previous = null;
    size--;
    return (E)pop;  
}

public boolean contains(Object find) {
    IntNode&lt;E&gt; temp = front;
    while(temp!=null){
        if(temp.equals((find))){
            return true;
        }else{
            temp = temp.link;
        }
    }
    return false;
 }  
</code></pre>

<p>}</p>
