Introduction
In this tutorial we will look at the use of Supplier a functional interface introduced in java 8.
Refer The video Tutorial for detail
Use Case
Supplier is a functional interface which is used to return data without accepting anything as parameter.The sample code is shown below.
//this accepts an argument & return a result.
Supplier<String> supplier=new Supplier<String>() {
@Override
public String get() {
return "Data from supplier functional interface ";
}
};
|
The above case Supplier will not receive anything but return the result. The function is returning a String.
Conclusion
In this tutorial we saw the use case of functional interface - Supplier. which is introduced in java 8 to act as supplier without receiving any parameter.