top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Why Stream.max(Integer::max) compiles in Java?

+2 votes
233 views

Why is Math::max acceptable while it's apparently not a Comparator

posted Aug 25, 2015 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

It relies on a concept which is informally known as "single abstract method (SAM)" interfaces. The basic idea is that any interface with one abstract method can be automatically implemented by any lambda or method reference, if the lambda or method reference matches the SAM in the interface.go to through the following for more detail:
http://www.programcreek.com/2014/01/why-stream-maxintegermax-compile/

answer Mar 14, 2016 by Shivam Kumar Pandey
...