When I did the test, I meet a problem with the stream.
The code is below:
public class HelloWorld {
public static void main(String []args) {
List<Integer> integers = Arrays.asList(-2, -5, -7, -16);
Integer integer = integers.stream().max(Math::max).orElse(0);
System.out.println(integer);
}
}
The return value is -15, the minimum number in the list. But when I change max() to min(), it returns me the max value. Why?