Java 8 DoubleSupplier Interface

7 months ago codedestine 0

In this tutorial, we will learn about Java 8 DoubleSupplier interface.

Java 8 DoubleSupplier Interface

DoubleSupplier Interface :-

DoubleSupplier ( java.util.function.DoubleSupplier ) is a functional interface that has one abstract method declared in it. This interface is double producing primitive specialised form of Supplier interface.

Abstract method :- 

double  getAsDouble (  ) :- The abstract method getAsDouble (  ) is a functional method. It does not accept any argument but return newly generated double values in the stream. It represents an operation by which you can generate new double values in the stream.

Reference :-  DoubleSupplier Interface JavaDocs 

Example :- 

This example will show you, how to create and call different methods of a DoubleSupplier interface.

  public static void main(String[] args){
    DoubleSupplier doubleSupplier = ( ) -> { return 5.5; };

Result :- 


That’s all for Java 8 DoubleSupplier Interface. If you liked it, please share your thoughts in comments section and share it with others too.