Hashmap with Streams in Java 8 Streams to collect value of Map

后端 未结 6 1937
悲&欢浪女
悲&欢浪女 2021-01-30 19:59

Let consider a hashmap

Map id1 = new HashMap();

I inserted some values into both hashmap.

For

6条回答
  •  你的背包
    2021-01-30 20:30

    Using keySet-

    id1.keySet().stream()
            .filter(x -> x == 1)
            .map(x -> id1.get(x))
            .collect(Collectors.toList())
    

提交回复
热议问题