AiStudentStudyRecord record = aiStudentStudyRecords.stream().max(Comparator.comparingLong(AiStudentStudyRecord::getId)).get();
public static void main(String[] args) {
// 一个集合中放入4个学生对象
List<Student> list = new ArrayList<>();
list.add(new Student(10002L, "ZhangSan", 19, 175.2));
list.add(new Student(10003L, "LiSi", 18, 180.1));
list.add(new Student(10004L, "Peter", 19, 170.8));
list.add(new Student(10001L, "KangKang", 18, 167.4));
// 打印默认顺序
System.out.println("默认顺序:");
list.stream().forEach(System.out::println);
// 按照id排序
System.out.println("id升序:");
list.stream().sorted(Comparator.comparing(Student::getId))
.forEach(System.out::println);
// 按照id逆序排列
System.out.println("id逆序:");
list.stream().sorted(Comparator.comparing(Student::getId).reversed())
.forEach(System.out::println);
// 按照年龄排序,再按照升高排序
System.out.println("age和height排序:");
list.stream().sorted(Comparator.comparing(Student::getAge).thenComparing(Student::getHeight))
.forEach(System.out::println);
//
// System.out.println("ai_student_question_log".toUpperCase());
//// Map<Long, Integer> knowledgeProportionMap = new HashMap<>();
//// List<StudentKnowledgeMasteryDto> rows = new ArrayList<>();
//// Long a = 100L;
//// for (int i = 0; i < 10; i++) {
//// StudentKnowledgeMasteryDto build = StudentKnowledgeMasteryDto.builder().knowledgeId(a).mastery(i).build();
//// rows.add(build);
//// }
//// //List 转map
//// knowledgeProportionMap = rows.stream().collect(Collectors.toMap(StudentKnowledgeMasteryDto::getKnowledgeId, StudentKnowledgeMasteryDto::getMastery, (u, h) -> h));
//// System.out.println(knowledgeProportionMap);
////
//// //List 转map
//// Map<Long, StudentKnowledgeMasteryDto> map2 = new HashMap<>();
//// map2 = rows.stream().collect(Collectors.toMap(StudentKnowledgeMasteryDto::getKnowledgeId, Function.identity(), (u, h) -> h));
//// System.out.println(map2);
////
//// //map3
//// Map<Long, List<StudentKnowledgeMasteryDto>> map3 = new HashMap<>();
//// map3 = rows.stream().collect(Collectors.groupingBy(StudentKnowledgeMasteryDto::getKnowledgeId));
//// System.out.println(map3);
////
////
//// // List<Integer>
//// List<Integer> courseList = rows.stream().map(f -> f.getMastery()).collect(Collectors.toList());
//// System.out.println(courseList);
public static void main(String[] args) {
AtomicReference<Integer> lowRiskStudentNum = new AtomicReference<>(0);
lowRiskStudentNum.updateAndGet(v -> v + 111);
System.out.println(lowRiskStudentNum.get());
}
List<QuestionDetailDto> questionDetailChildrenCombList = aiPaperQuestionList.stream().filter(questionDetailDto ->
questionDetailDto.getParentId() != null
&& questionDetailDto.getParentId() != 0 && questionDetailDto.getQuestionTypeId() != 6).collect(Collectors.toList());
//
//
//// nodeDtoList = nodeDtoList.stream().filter(dto -> dto.getPointType().equals(2)).collect(Collectors.toList());
// List<Long> teacherIds = aiClassesList.stream().map(AiClasses::getTeacherUserId).distinct().collect(Collectors.toList());
// Long[] longs = teachingPlanIdList.stream().toArray(Long[]::new);
//
// }
stream
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 最近使用Apache poi 做excel导出的功能,遇到了如下问题: 起初对比其他的web工程,没有发现如何解决...
- 创建消息Producer服务,配置消息主题 这里新建了一个controller,controller里面有一个接口...
- 在主流的编程语言中,Java一直走在简化并发编程任务的最前沿。1996年Java发布时,就通过同步和wait/no...
- 常用的流操作 在深入原理之前,我们有必要知道关于Stream的一些基础知识,关于Stream的操作分类,如表1-1...