Java 8 Supplier example

In this post, we are going to see about java 8 Supplier interface.
Supplier is functional interface which does not take any argument and produces result of
typeT.It has a functional method called
Tget() As Supplier is functional interface, so it can be used as assignment target for lambda expressions.

As you want see we have used
supplier as
()->newRandom().nextInt(10) to generate random numbers.
limit(5)is used to limit the stream to 5 elements only and also used Java 8 foreach loop to print elements of the Stream.
That’s all about Java 8 Supplier example.