-
获取list对象中的指定字段 List<Long> userId= scheduleStudents.stream().map(User::getUserId).collect(Collectors.toList()); List<Long> ids = list.stream().map(u-> u.getUserId()).collect(Collectors.toList());
- string转list<String>
List<String> idList = Arrays.asList(componentRelate.getIds().split(","));
- string转list<Long>
List<Long> idList = Arrays.asList(componentRelate.getIds().split(",")) .stream().map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
- 对象互转
List<CourseScheduleBase> finishCourse = finishCourseSchedules.stream().map(a->{ return getScheduleBase(a); }).collect(Collectors.toList());
stream灵活应用,list和String互转
于 2022-03-25 10:52:51 首次发布