How to transform List to Map with Google collections?

前端 未结 5 741
名媛妹妹
名媛妹妹 2021-02-01 12:53

I have a list of strings and I have a function to generate a value for each key in the list.

I want to create a map using this function. Can I do this with Google collec

5条回答
  •  既然无缘
    2021-02-01 13:08

    Using Guava + Lambda

     Map map = Maps.uniqueIndex(YourList, YourCustomClass -> YourCustomClass.getKey());
    

提交回复
热议问题