Sunday, July 19, 2015

Java Lambda - IntBinaryOperator Functional Interface

IntBinaryOperator Functional Interface

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

IntBinaryOperator represents an operation of two int valued operands and producing int valued result.

applyAsInt() method
int applyAsInt(int left, int right);

This method applies this operator to given operands.
IntBinaryOperator intBinOp = (a, b) -> a + b;
int result = intBinOp.applyAsInt(4, 5);
System.out.println(result);

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