Java: how to transform from List to Map without iterating

前端 未结 4 1721
予麋鹿
予麋鹿 2020-12-30 03:56

I have a list of objects that I need to transform to a map where the keys are a function of each element, and the values are lists of another function of each element. Effec

4条回答
  •  无人及你
    2020-12-30 04:49

    There has been some discussion in adding one API in Apache's CollectionUtils to transform a List to Map, but then I dont see any reason for not using a foreach contruct, Is there any problem that you are facing ? Transform will do the same thing which you can get easily by foreach, looping cannot be avoided.

    EDIT:

    Here is the link to discussion in Apache's forum http://apache-commons.680414.n4.nabble.com/Convert-List-to-Map-td747218.html

提交回复
热议问题