Sunday, July 19, 2015

Java Lambda - LongBinaryOperator Functional Interface

LongBinaryOperator Functional Interface

LongBinaryOperator is a primitive type specialization or primitive version of BinaryOperator for long data type. I would highly recommend reading about BinaryOperator Interface before reading this post.

LongBinaryOperator represents an operation of two long valued operands and producing long valued result. Previously we also discussed about IntBinaryOperator Interface.

applyAsLong() method
long applyAsLong(long left, long right);

This method applies this operator to given operands.
LongBinaryOperator longBinOp = (a, b) -> a + b;
long result = longBinOp.applyAsLong(4, 5);

That’s all on LongBinaryOperator 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