To check if an element exists in the Stacked List
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.

*******************************************************************************************

public class LinkedListStack<E> implements Stack<E> {

	IntNode<E> front;
	IntNode<E> current = front, previous;
	private int size =0;


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


	public E pop() {		
		IntNode<E> pop = current;
		current = previous;
		previous = null;
		size--;
		return (E)pop;	
	}

	public boolean contains(Object find) {
		IntNode<E> temp = front;
		while(temp!=null){
			if(temp.equals((find))){
				return true;
			}else{
				temp = temp.link;
			}
		}
		return false;
	}	
}
To check if an element exists in the Stacked List
===

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.

*******************************************************************************************

public class LinkedListStack<E> implements Stack<E> {

	IntNode<E> front;
	IntNode<E> current = front, previous;
	private int size =0;


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


	public E pop() {		
		IntNode<E> pop = current;
		current = previous;
		previous = null;
		size--;
		return (E)pop;	
	}

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