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);

Integer::compareTo i.e. public int compareTo(Integer b) in Integer is an instance method, therefore it fits the Comparator functional interface by accepting one parameter as this, and the second as the method parameter.

Therefore (a, b) -> Comparator.compare(a, b) and (a, b) -> a.compareTo(b) are both acceptable as lambda parameters.
