lists removing

Solutions on MaxInterview for lists removing by the best coders in the world

showing results for - "lists removing"
Greta
05 Mar 2020
1List<String> names = new ArrayList<>(List.of("John Doe", "Jack Doe", "John Smith"));
2
3List<String> johns = new ArrayList<>();
4for (String name: names) {
5    if (name.startsWith("John")) {
6        johns.add(name);
7    }
8}
9names.removeAll(johns);
similar questions
queries leading to this page
lists removing