Lambda用法

从List对象中取出对象的某个元素,组成新的List

List<Integer> userIds = userList.stream().map(u -> u.getId()).collect(Collectors.toList());
还可以再精简一点
List<String> abilityList = abilitys.stream().map(StudyProAbility::getAbilityName).collect(Collectors.toList());

Last modification:October 31st, 2019 at 11:07 am
如果觉得我的文章对你有用,请随意赞赏

Leave a Comment