Java8: HashMap to HashMap using Stream / Map-Reduce / Collector

前端 未结 9 2144
无人及你
无人及你 2020-11-30 18:38

I know how to \"transform\" a simple Java List from Y -> Z, i.e.:

List x;
List y = x.stre         


        
9条回答
  •  旧时难觅i
    2020-11-30 19:05

    The declarative and simpler solution would be :

    yourMutableMap.replaceAll((key, val) -> return_value_of_bi_your_function); Nb. be aware your modifying your map state. So this may not be what you want.

    Cheers to : http://www.deadcoderising.com/2017-02-14-java-8-declarative-ways-of-modifying-a-map-using-compute-merge-and-replace/

提交回复
热议问题