📜  列表 - 使用迭代器删除 - Java 代码示例

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

代码示例1
List names = new ArrayList<>(List.of("John Doe", "Jack Doe", "John Smith"));
Iterator it = names.iterator();
while (it.hasNext()) {
    String name = it.next();
    if (name.startsWith("John")) {
        it.remove();
    }
}