The Supplier functional interface is also a type of functional interface that does not take any input
or argument and returns a single output.
The Supplier interface takes only one generic type, the type of data it is going to return.
It is having only one method as get() and there is no other method.
The get() is the abstract method of the Supplier.
If we want to implement of a lambda expression
with the predefined functional interface and supply our object and don’t want to to provide input.
So, we prefer the Supplier Predefined Functional Interface.
public static void main(String[] args) { Supplier
<String
>supplier = () -> "Hello World"; System.out.println(supplier.get()); } Output: Hello World
public static void main(String[] args) { Supplier
<Integer
>supplier = () -> 500; System.out.println(supplier.get()); } Output: 500
public static void main(String[] args) { Supplier
<Integer
>supplier = () -> 100; System.out.println(supplier.get()); } Output: 100
public static void main(String[] args) { Supplier
<Date
>dateSupplier = ()->new Date();; System.out.println(dateSupplier.get()); } Output: Sun Mar 31 10:37:48 IST 2024