stream

 AiStudentStudyRecord record = aiStudentStudyRecords.stream().max(Comparator.comparingLong(AiStudentStudyRecord::getId)).get();

public static void main(String[] args) {

       // 一个集合中放入4个学生对象
        List 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 knowledgeProportionMap = new HashMap<>();
////        List 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 map2 = new HashMap<>();
////        map2 = rows.stream().collect(Collectors.toMap(StudentKnowledgeMasteryDto::getKnowledgeId, Function.identity(), (u, h) -> h));
////        System.out.println(map2);
////
////        //map3
////        Map> map3 = new HashMap<>();
////        map3 = rows.stream().collect(Collectors.groupingBy(StudentKnowledgeMasteryDto::getKnowledgeId));
////        System.out.println(map3);
////
////
////        // List
////        List courseList = rows.stream().map(f -> f.getMastery()).collect(Collectors.toList());
////        System.out.println(courseList);



    public static void main(String[] args) {
        AtomicReference lowRiskStudentNum = new AtomicReference<>(0);
        lowRiskStudentNum.updateAndGet(v -> v + 111);
        System.out.println(lowRiskStudentNum.get());
    }





    List 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 teacherIds = aiClassesList.stream().map(AiClasses::getTeacherUserId).distinct().collect(Collectors.toList());


//   Long[] longs = teachingPlanIdList.stream().toArray(Long[]::new);
//
//    }

你可能感兴趣的:(stream)