我不想迭代器遍历,想找个短点的方式,但是查了一下没满意的,自己搞一个,比较初级的代码
public static void main(String[] args) {
List<String> l =new ArrayList<>();
l.add("2、");
l.add("3、");
Map<String, String> m = new ConcurrentHashMap<>();
m.put("1、", "qeqweda");
m.put("2、", "qweqwe");
m.put("3、", "qwe qwe");
m.put("4、", "qweqwe qeqe");
m.put("5、", "eqweqe");
//下面两行二选一,都行
m.keySet().removeIf(l::contains);
//l.forEach(m::remove);
m.keySet().forEach(System.out::print);
}
结果
1、5、4、