Java 8 ObjDoubleConsumer Interface
7 years ago Lalit Bhagtani 0
In this tutorial, we will learn about Java 8 ObjDoubleConsumer interface.
ObjDoubleConsumer Interface :-
ObjDoubleConsumer ( java.util.function.ObjDoubleConsumer ) is a functional interface that has one abstract method declared in it. This interface is a specialised form of BiConsumer interface.
Abstract method :-
void accept ( T t , double value ) :- The abstract method accept ( T t , double value ) is a functional method. It accepts two parameters as an argument ( one generic object and second double value ) and return no value, it performs the operation defined by the ObjDoubleConsumer interface ( usually a lambda expression passed as an argument ).
Reference :- ObjDoubleConsumer Interface JavaDocs
Example :-
In this example, we will declare a ObjDoubleConsumer interface that prints the value of a parameter passed as a argument.
public static void main(String[] args){ ObjDoubleConsumer<String> biConsumer = ( x , y ) -> { System.out.println(x + " " +y);}; // Example of accept biConsumer.accept("Interface",2.00); }
Result :-
Interface 2.0
That’s all for Java 8 ObjDoubleConsumer Interface. If you liked it, please share your thoughts in comments section and share it with others too.