📜  列表 - 删除 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:16.489000             🧑  作者: Mango

代码示例1
List names = new ArrayList<>(List.of("John Doe", "Jack Doe", "John Smith"));

List johns = new ArrayList<>();
for (String name: names) {
    if (name.startsWith("John")) {
        johns.add(name);
    }
}
names.removeAll(johns);