InterviewSolution
| 1. |
What are the types and common ways to use lambda expressions? |
|
Answer» A lambda expression does not have any specific type by itself. A lambda expression RECEIVES type once it is assigned to a functional INTERFACE. That same lambda expression can be assigned to different functional interface types and can have a different type. For eg consider expression s -> s.isEmpty() : PREDICATE<String> stringPredicate = s -> s.isEmpty(); Common ways to USE the expression Assignment to a functional Interface —> Predicate<String> stringPredicate = s -> s.isEmpty(); |
|