package class10_2_ArrayLists; import java.util.ArrayList; public class CardDriver3 { public static void main(String[] args) { CardDriver3 driver = new CardDriver3(); ArrayList hand = new ArrayList(); hand.add(new Card(1,"Hearts")); hand.add(new Card(2,"Hearts")); hand.add(new Card(3,"Hearts")); hand.add(new Card(4,"Hearts")); hand.add(new Card(1,"Hearts")); //Card c = hand.remove(3); Card ace = new Card("Ace of Hearts"); Card fromHand = hand.get(0); if(fromHand != null && fromHand.equals(ace)) { System.out.println("Everything's OK."); } else { System.out.println("Cards do not match!"); } int index = hand.indexOf(ace); System.out.println("index:"+index); System.out.println("index:"+hand.lastIndexOf(ace)); driver.printHand(hand); } /** * Print all the cards in the hand * @param cards list of cards */ private void printHand(ArrayList cards) { // for(int i = 0; i < cards.size(); i++ ) { // System.out.println("Card: "+cards.get(i).toString()); // } for(Card c:cards) { System.out.println("Card: "+c); } } }