How to delete certain cards that has been used from player hand? [closed]


I am programming the game in Java. I am using Java ArrayList to store the cards. But do a ignore case string check on the cards, the problem is it is deleting the cards with the name "Trooper", but it always leave one trooper card in the player hand. I wanted it to leave all trooper cards.

Card Display in Java Console: Trooper Agent Agent Agent Trooper Trooper

Jave Code:

if(mouseCursor.getRectangle().intersects(placeList.get(i).getRectangle())                         && mouseCursor.isPressed() )                         {                              if(attackPower >= placeList.get(i).getAttackPower())                             {                                 for(int j = 0 ; j < playerDisplayDeck.size();j++)                                 {                                     System.out.println(playerDisplayDeck.get(j).getName());                                 }                                                                  for(int j = 0 ; j < playerDisplayDeck.size();j++)                                 {                                      if(playerDisplayDeck.get(j).getName().equalsIgnoreCase("trooper"))                                     {                                         playerDisplayDeck.remove(j);                                     }                                 }                                                                  for(int j = 0 ; j < playerDisplayDeck.size();j++)                                 {                                     System.out.println(playerDisplayDeck.size());                                 }                                                                  attackPower = attackPower - placeList.get(i).getAttackPower(); }