Sunday, July 19, 2015

Java Lambda - ObjDoubleConsumer Functional Interface

ObjDoubleConsumer Functional Interface

ObjDoubleConsumer represents an operation that accepts an argument of type T or object-valued argument and double valued argument and returns no result.

This is the specialization of BiConsumer interface. We have discussed it previously. BiConsumer interface represents two input (object) arguments and returns no result. BiConsumer is two-arity specialization of Consumer interface.

accept() method
void accept(T t, double value);

performs this operation on given arguments.  Let us take simple example to accept String object and double value.
ObjDoubleConsumer<String> objDoubleConsumer = (final String t, final double a) -> {
            String result = t.concat(String.valueOf(a));
      objDoubleConsumer.accept("Number is ", 10); //Outputs Number is 10.0

That’s all on ObjDoubleConsumer Interface.

Read about important java.util.function package’s interface here. Consumer, Function, Supplier, BinaryOperator & Predicate Functional Interfaces. I have also written on High Order functions using Function functional interface.

No comments:

Post a Comment

Ads Inside Post