Flattening a collection

前端 未结 9 2046
走了就别回头了
走了就别回头了 2020-11-30 02:55

Say I have a Map>

I can get the values of the map easily enough, and iterate over it to produce a single

9条回答
  •  醉酒成梦
    2020-11-30 03:19

    If you are using Java 8, you could do something like this:

    someMap.values().forEach(someList::addAll);
    

提交回复
热议问题