Stream#max(Comparator)takes value Comparator. You want to use Integer#compare(int, int)as a comparison function.
list.stream().max(Integer::compare).get()
You provided Integer#max(int, int)as an implementation Comparator#compare(int, int). This method does not meet the requirements Comparator#compare. Instead of returning a value indicating that it is the largest, it returns the value of the largest.
source
share