-
Notifications
You must be signed in to change notification settings - Fork 1
Lambda
Anuj Jain edited this page Jan 15, 2021
·
3 revisions
Functional Interface
- A lambda function implements a Functional Interface
- A functional interface:
- have only one abstract method.
- have as many default, static methods.
- can have methods from object class.
- @FunctionalInterface may be used on functional Interface.
Define functional interface
@FunctionalInterface
public interface Supplier<T> {
T get();
}
Implement
Supplier<String> supplier = () -> "Hello World!";
Call
System.out.printf("%s %s", "Output", supplier.get());
- Avoid Auto-boxing, Auto-unboxing