What is a supplier in Java 8?
A supplier is a simple functional interface in Java 8 that does not take in any argument. It is used as an assignment target when making use of lambda expressions.
The following is an example that denotes the usage of a supplier:
import java.util.function.Supplier;
public class Java8SupplierExample {
public static void main(String[] args) {
Supplier supplier= ()-> "HelloLearners";
System.out.println(supplier.get());
}
}