摘要: 其实map主要是操作集合中的每一个元素1.对象列表 - >字符串列表 List<String> collect = staff.stream().map(x -> x.getName()).collect(Collectors.toList()); 2.对象列表 - >其他对象列表 List<Sta 阅读全文
posted @ 2021-08-03 18:04 郭慕荣 阅读(119) 评论(0) 推荐(0) 编辑
摘要: list转map在Java8中stream的应用1.利用Collectors.toMap方法进行转换 public Map<Long, String> getIdNameMap(List<Account> accounts) { return accounts.stream().collect(Co 阅读全文
posted @ 2021-08-03 17:16 郭慕荣 阅读(3142) 评论(0) 推荐(0) 编辑