Java.util.function.IntBinaryOperator interface with Examples Last Updated : 18 Jul, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report The IntBinaryOperator interface was introduced in Java 8. It represents an operation on two int values and returns the result as an int value. It is a functional interface and thus can be used as a lambda expression or in a method reference. It is mostly used when the operation needs to be encapsulated from the user. Methods applyAsInt(): This function takes two int values, performs the required operation and returns the result as an int. public int applyAsInt(int val1, int val2) Example to demonstrate IntBinaryOperator interface as a lambda expression . Java // Java program to demonstrate IntBinaryOperator import java.util.function.IntBinaryOperator; public class IntBinaryOperatorDemo { public static void main(String[] args) { // Binary operator defined to divide // factorial of two numbers IntBinaryOperator binaryOperator = (x, y) -> { int fact1 = 1; for (int i = 2; i <= x; i++) { fact1 *= i; } int fact2 = 1; for (int i = 2; i <= y; i++) { fact2 *= i; } return fact1 / fact2; }; System.out.println("5! divided by 7! = " + binaryOperator.applyAsInt(5, 7)); System.out.println("7! divided by 5! = " + binaryOperator.applyAsInt(7, 5)); } } Output: 5! divided by 7! = 0 7! divided by 5! = 42 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/function/IntBinaryOperator.html Comment More infoAdvertise with us Next Article Java.util.function.BiPredicate interface in Java with Examples C CharchitKapoor Follow Improve Article Tags : Java Java - util package Java-Functional-Interfaces Practice Tags : Java Similar Reads Java.util.function.IntPredicate interface in Java with Examples The IntPredicate interface was introduced in JDK 8. This interface is packaged in java.util.function package. It operates on an integer value and returns a predicate value based on a condition. It is a functional interface and thus can be used in lambda expression also. public interface IntPredicate 2 min read Java.util.function.LongBinaryOperator interface with Examples The LongBinaryOperator interface was introduced in Java 8. It represents an operation on two long values and returns the result as a long value. It is a functional interface and thus can be used as a lambda expression or in a method reference. It is mostly used when the operation needs to be encapsu 1 min read IntConsumer Interface in Java with Examples The IntConsumer Interface is a part of the java.util.function package which has been introduced since Java 8, to implement functional programming in Java. It represents a function which takes in one int-valued argument but does not return any value. The lambda expression assigned to an object of Int 3 min read Java.util.function.BiPredicate interface in Java with Examples The BiPredicate<T, V> interface was introduced in JDK 8. This interface is packaged in java.util.function package. It operates on two objects and returns a predicate value based on that condition. It is a functional interface and thus can be used in lambda expression also. public interface BiP 2 min read Inflater getAdler() function in Java with examples The getAdler() function of the Inflater class returns the Adler-32 value of the uncompressed data. Adler-32 is a checksum algorithm which is widely used zlib compression library. Function Signature: public int getAdler() Syntax: i.getAdler(); Parameter: The function requires no parameter Return Type 2 min read Java.util.function.DoubleBinaryOperator interface with Examples The DoubleBinaryOperator interface was introduced in Java 8. It represents an operation on two double values and returns the result as a double value. It is a functional interface and thus can be used as a lambda expression or in a method reference. It is mostly used when the operation needs to be e 2 min read Like