Lists - removing code example
Example: Lists - removing
List<String> names = new ArrayList<>(List.of("John Doe", "Jack Doe", "John Smith"));
List<String> johns = new ArrayList<>();
for (String name: names) {
if (name.startsWith("John")) {
johns.add(name);
}
}
names.removeAll(johns);