IndexOutOfBoundsException ArrayList Error
<p>I'm writing a basic java card game but I'm getting a
<code>java.lang.IndexOutOfBoundsException: Index: 6, Size 6 (in java.util.ArrayList</code> error on this bit of code, could you help me please?</p>

<pre><code> public void simple() { 
        if (cards.get(cards.size()-1).getSuit().equals(cards.get(cards.size()).getSuit())) { 

            int last=cards.size()-1;
            Card c=cards.remove(last);
            cards.set(last-1,c);

        }
        else {
            System.out.println("hi");
        }
    }
</code></pre>
