You need to replace
.max(Integer::max)
with
.max(Integer::compare)
The problem here is that the abstract method compare is declared to return an int value and that is also satisfied by the signature of Integer.max along with method Integer.compare in the Integer class, hence the representation Integer::max is inferred as a valid Comparator. Though the compare method is expected to be implemented such as it:
Returns a negative integer, zero, or a positive integer as the first
argument is less than, equal to, or greater than the second.
In your current scenario, the code always ends up returning a positive value (given the input) and therefore the first element in comparison is considered to be greater always and thus returned accordingly.