JAVA8List排序,(升序,倒序)

  List<Integer> integerList = Arrays.asList(4, 5, 2, 3, 7, 9);
        List<Integer> collect = integerList.stream()
                .map(i -> i * i).distinct()
                .collect(Collectors.toList());
//        Collections.sort(collect);  //升序
        collect.sort(Comparator.reverseOrder()); //倒序
        collect.forEach(System.out::println);

 

posted @ 2018-03-23 17:24  咸鱼也疯狂  阅读(39122)  评论(0编辑  收藏  举报
Fork me on GitHub