@Test public void testMapLambda() { Map<String, Object> map = new ConcurrentHashMap<>(); map.put("A", 10); map.put("B", 20); map.put("C", 30); map.put("D", 40); map.put("E", 50); map.put("F", 60); List<String> arraylist = new CopyOnWriteArrayList<>(); map.forEach((key, value) -> { arraylist.add(key); map.remove(key); }); arraylist.stream().filter(key-> key.contains("B") || key.contains("C")).forEach(key->{ arraylist.add(key); }); arraylist.forEach(v->{ System.out.println(v); }); }
转载于:https://my.oschina.net/u/3744350/blog/1634429