I am trying to add "Luis" 3 times to array list and then remove "Luis" so there is only one "Luis". Seems to be a problem with the if.
import java.util.ArrayList;
public class Menu {
private ArrayList<String> meals;
public Menu() {
this.meals = new ArrayList<String>();
}
// Implement the methods here
public void addMeals() {
this.meals.add("Luis");
this.meals.add("Luis");
this.meals.add("Luis");
for (String container : this.meals) {
for (int counter = 0; counter < this.meals.size(); counter++) {
***if (counter > 1 && this.meals.contains(container)) {
this.meals.remove(this.meals.indexOf(container));
}***
}
}
System.out.println(this.meals);
}
}