Tag: max

在Java中使用Lambda表达式查找Max

这是我的代码 List ints = Stream.of(1,2,4,3,5).collect(Collectors.toList()); Integer maxInt = ints.stream() .max(Comparator.comparing(i -> i)) .get(); System.out.println(“Maximum number in the set is ” + maxInt); 输出: Maximum number in the set is 5 我不能在我的代码的下面部分中的两个之间进行distingues Comparator.comparing(i -> i) 任何人都可以善良并解释两个i之间的区别吗?

我如何找到数组中的最大值?

在java中,我需要能够通过一个数组并找到最大值。 我如何比较数组的元素以找到最大值?