I am trying to remove an arraylist within a list of arraylists but it does not seem to be working. In context of my code, I have multiple routes which are in an arraylist. Each route is a arraylist of places.
public static void removeBadRoutes(ArrayList<ArrayList<Place>> routes, Expedition e) {
for(int i = 0; i < routes.size(); i++) {
if(!isGoodRoute(routes.get(i), e)) {
routes.remove(routes.get(i));
}
}
}
I also tried routes.remove(i) which didnt do anything. Edit: By "not working" I mean that nothing is being removed, it still displays routes which should have been removed based on my condition.