Get list of attributes of an object in an List

前端 未结 8 1717
青春惊慌失措
青春惊慌失措 2020-12-12 19:12

When there is an List, is there a possibility of getting List of all person.getName() out of that? Is there an prepared call for that

8条回答
  •  自闭症患者
    2020-12-12 19:27

    There is no other way to do this in Java than the one you suggested, at least as long as you are sticking with the standard Java Collection API.

    I have been wishing for something like this for a long time... Especially since I tasted the sweet freedom of Ruby, which has wonderful things like collect and select working with closures.

提交回复
热议问题