1.对象中的属性转map 通过Collectors.toMap
list.stream().collect(Collectors.toMap(Person::getId,Person::getName));
2.收集对象本身
list.stream().collect(Collectors.toMap(Person::getId,list->list)
如果觉得《stream流把list转为map》对你有帮助,请点赞、收藏,并留下你的观点哦!
时间:2021-12-19 15:43:38
1.对象中的属性转map 通过Collectors.toMap
list.stream().collect(Collectors.toMap(Person::getId,Person::getName));
2.收集对象本身
list.stream().collect(Collectors.toMap(Person::getId,list->list)
如果觉得《stream流把list转为map》对你有帮助,请点赞、收藏,并留下你的观点哦!
Java8 Stream List<Bean> 或List<Map> 转Map
2024-02-24
Java list中的对象转为list list中的对象转为map
2022-01-06
失眠复发了3次 我不会再惧怕第4次 因为我找到了破解失眠的根
2024-07-29