Java.util.function.DoubleBinaryOperator interface with Examples Last Updated : 18 Jul, 2019 Comments Improve Suggest changes Like Article Like Report 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 encapsulated from the user. Methods: applyAsDouble(): This function takes two double values, performs the required operation and returns the result as a double. public double applyAsDouble(double val1, double val2) Example to demonstrate DoubleBinaryOperator interface as a lambda expression . Java // Java program to demonstrate DoubleBinaryOperator import java.util.function.DoubleBinaryOperator; public class DoubleBinaryOperatorDemo { public static void main(String[] args) { double x = 7.654; double y = 5.567; // Representing addition as // the double binary operator DoubleBinaryOperator doubleBinaryOperator = (a, b) -> { return a + b; }; System.out.println("x + y = " + doubleBinaryOperator .applyAsDouble(x, y)); // Representing subtraction as // the double binary operator doubleBinaryOperator = (a, b) -> { return a - b; }; System.out.println("x - y = " + doubleBinaryOperator .applyAsDouble(x, y)); // Representing multiplication as // the double binary operator doubleBinaryOperator = (a, b) -> { return a * b; }; System.out.println("x * y = " + doubleBinaryOperator .applyAsDouble(x, y)); // Representing division as // the double binary operator doubleBinaryOperator = (a, b) -> { return a / b; }; System.out.println("x / y = " + doubleBinaryOperator .applyAsDouble(x, y)); // Representing remainder operation // as the double binary operator doubleBinaryOperator = (a, b) -> { return a % b; }; System.out.println("x % y = " + doubleBinaryOperator .applyAsDouble(x, y)); } } Output: x + y = 13.221 x - y = 2.0869999999999997 x * y = 42.609818000000004 x / y = 1.3748877312735763 x % y = 2.0869999999999997 Reference: https://docs.oracle.com/javase/8/docs/api/java/util/function/DoubleBinaryOperator.html Comment More infoAdvertise with us Next Article Java.util.function.DoubleBinaryOperator interface with Examples C CharchitKapoor Follow Improve Article Tags : Java Java - util package Java-Functional-Interfaces Practice Tags : Java Similar Reads Java.util.function.DoublePredicate interface in Java with Examples The DoublePredicate interface was introduced in JDK 8. This interface is packaged in java.util.function package. It operates on a Double object 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 DoublePred 2 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 DoubleFunction Interface in Java with Examples The DoubleFunction 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 a double-valued argument and produces a result of type R. This functional interface takes in only one 1 min read Java 8 | DoubleSupplier Interface with Examples The DoubleSupplier 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 does not take in any argument but produces a double value. The lambda expression assigned to an object of Doubl 1 min read Java 8 | DoubleToIntFunction Interface in Java with Example The DoubleToIntFunction 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 a double-valued argument and gives an int-valued result. The lambda expression assigned to an obj 1 min read Map.Entry interface in Java with example Map.Entry interface in Java provides certain methods to access the entry in the Map. By gaining access to the entry of the Map we can easily manipulate them. Map.Entry is a generic and is defined in the java.util package. Declaration : Interface Map.Entry k -> Key V -> Value Methods: equals (O 4 min read DoubleAdder intValue() method in Java with Examples The java.DoubleAdder.intValue() is an inbuilt method in java that returns the sum() as an int after a narrowing primitive conversion. When the object of the class is created its initial value is zero. Syntax: public int intValue() Parameters: This method does not accepts any parameter. Return Value: 1 min read Java 8 | DoubleToLongFunction Interface in Java with Examples The DoubleToLongFunction 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 a double-valued argument and gives an long-valued result. The lambda expression assigned to an o 1 min read DoubleAccumulator intValue() method in Java with Examples The Java.DoubleAccumulator.intValue() is an inbuilt method in java that returns the current value as an int after a narrowing primitive conversion. The initial datatype is double which is explicitly converted into type int without accepting any parameters. Syntax: public int intValue() Parameters: T 2 min read Deflater deflate() function in Java with examples The deflate() function of the Deflater class in java.util.zip is used to compress the input data and fill the given buffer with the compressed data. The function returns the number of bytes of the compressed data. Function Signature: public int deflate(byte[] b) public int deflate(byte[] b, int offs 4 min read Like