Grokking Java Interview Questions
0% completed
Lambdas and Functional Interfaces
Predicate<Integer> cheap = price -> price < 100; Object rule = price -> price < 100;
Both lines contain the same text after the equals sign. The first line compiles, and the second fails with the message incompatible types: Object is not a functional interface.
The text after the equals sign is a lambda, which is a short form of a method without a name. The four questions below start with the kind of interface that a lambda needs. They then cover the interfaces that the JDK supplies, the code that the compiler produces, and the methods that join two functions into one.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%