The Stream.max()
takes an argument of type Comparator
, which contains the compare()
method; The compare method takes two arguments and returns an int
. So we can use a method to refer to Integer#compare()
as an argument to the max()
method; But Integer.compareTo()
accepts only one parameter, which does not match the number of parameters of the compare()
method, so why can it also be used as a parameter of max()
?
that's my code:
Integer maxMenuTp = menuTpList.stream().max(Integer::compareTo);