Advertisement
nikeza

Remove from List<> index

Oct 17th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1.  public void remove(String author) {
  2.         int size = this.gladiators.size();
  3.         int index = -1;
  4.         for (int i = 0; i < size; i++) {
  5.             if (this.gladiators.get(i).getName().equals(author)) {
  6.                 index = i;
  7.                 gladiators.remove(gladiators.get(index));
  8.                 this.count--;
  9.                 break;
  10.             }
  11.         }
  12.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement