• [Java] Stream Sort


    Sream<Employee> emps = ...;
    
    emps.sorted(
        Comparator.comparingInt(Employee::getSalary)
                          .reversed()
        ).limit(10)
        .map(Employee::getName)
        .forEachOrdered(System.out::println);

    ParalleSteam with unordered() to improve efficiency:

    List<Integer> list = ...;
    
    long n = list.parallelStream()
                      .unordered()
                      .distinct()
                       count();
  • 相关阅读:
    文件路径与操作系统
    试验10
    shiyan9
    sql
    shiyan8
    iostream
    shiyan7
    CDMA
    试验6
    试验5
  • 原文地址:https://www.cnblogs.com/Answer1215/p/14295622.html
Copyright © 2020-2023  润新知