[Solved] add or remove a string from a list based on an if statement


Why not do this:

for(int i=0; i<selectedPlanet.size(); i++) {
    if(planet.isChecked()) {
        selectedPlanets.add(planet.getDisplayName()); 
    } else {
       selectedPlanets.remove(planet.getDisplayName()); 
    }
}

6

solved add or remove a string from a list based on an if statement