How is a Method reference compatible with functional interface with different implementing function names?

前端 未结 1 1332
无人共我
无人共我 2021-01-28 05:28

Here, a reference to the static method isPrime( ) is passed as the first argument to numTest( ). This works because isPrime is compatible with the IntPredicate functional interf

相关标签:
1条回答
  • 2021-01-28 05:40

    This is an example of lambdas at work. It is new in java 8 and it basically allows the runtime to create an instance of the functional interface for you with the implementation you define.

    Brian Goetz has written a doc on how lambdas (and method references) work at compile and runtime.

    0 讨论(0)
提交回复
热议问题