Remove element from linked list JAVA
<p>OK here is my problem.  I have a linked list of card objects.</p>

<p>I have the following method</p>

<pre><code>  public void removeCard(Card card){
        cards.remove(card);

  }
</code></pre>

<p>if I create Card c = new Card(5,C); for example</p>

<p>and there is a card with the exact same values 2, and C in the linked list (cards).</p>

<p>If I call the method  CardPile.remove(card)<br />
I dont get any errors, but the element that's equal to the parameter card is not removed.
Any ideas why this is not happening?</p>

<pre><code>import java.util.LinkedList;

public class CardPile {

    final char [] suit = {'C','D','H','S'};
    final char [] rank = {'A','2','3','4','5','6','7','8','9','T','J','Q','K'};

    LinkedList&lt;Card&gt; cards;


    public CardPile(){
            cards = new LinkedList&lt;Card&gt;();
    }


    public void addCard(Card card){
            cards.addLast(card);
    }
    public void removeCard(Card card){
            cards.remove(card);

    }
    public void removeSpecial(Card card){
            LinkedList&lt;Card&gt; temp = new LinkedList&lt;Card&gt;();
            for(int i=0; i&lt;cards.size(); i++){
                    if(cards.get(i).equals(card)){
                            temp.add(cards.get(i));

                    }
            }
            cards = temp;
    }

    public void listCards(){
            for(int i=0; i&lt;cards.size(); i++){
                    System.out.print(cards.get(i).toString()+" ");
            }
            System.out.println();
    }

    public boolean isEmpty(){
            if(cards.size()==0)
                    return true;
            else
                    return false;
    }

    public Card drawCard(){
            return cards.removeLast();
    }

    public boolean hasCard(Card card){
            int index = 0;
            boolean contained = false;
            if(cards.size()==0){
                    System.out.println("error, cards size is 0");
                    return false;
            }
            else{
                    while(index&lt;cards.size() &amp;&amp; !contained){
                            if(cards.get(index).isEqual(card)){
                                    System.out.println("Card found");
                                    contained=true;
                            }
                            index++;
                    }
            }

            return contained;
    }
}
</code></pre>
