Finding Max with Lambda Expression in Java

前端 未结 3 1558
孤城傲影
孤城傲影 2020-12-17 15:23

This is my code

    List ints = Stream.of(1,2,4,3,5).collect(Collectors.toList());
    Integer maxInt = ints.stream()
                                 


        
3条回答
  •  情书的邮戳
    2020-12-17 15:48

    Comparator.comparing expects a function which maps the source object to the value which actually gets compared - in your case, as you don't want to pre-process the value to be compared, i is simply mapped to itself.

提交回复
热议问题