Java.util.function.DoublePredicate interface in Java with Examples Last Updated : 22 Sep, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 DoublePredicate Methods test(): This function evaluates a conditional check on the double value, and returns a boolean value denoting the outcome. boolean test(double value)and(): This function applies the AND operation on the current object and the object received as argument, and returns the newly formed predicate. This method has a default implementation. default DoublePredicate and(DoublePredicate other)negate(): This function returns the inverse of the current predicate i.e reverses the test condition. This method has a default implementation. default DoublePredicate negate()or(): This function applies the OR operation on the current object and the object received as argument, and returns the newly formed predicate. This method has a default implementation. default DoublePredicate or(DoublePredicate other) Example: Java // Java example to demonstrate DoublePredicate interface import java.util.function.DoublePredicate; public class DoublePredicateDemo { public static void main(String[] args) { // DoublePredicate to check square // of x is less than 100 DoublePredicate db = (x) -> { return x * x < 100.0; }; System.out.println("100 is less than 100 " + db.test(10)); DoublePredicate db3; // Test condition reversed db.negate(); System.out.println("100 is greater than 100 " + db.test(10)); DoublePredicate db2 = (x) -> { double y = x * x; return y >= 36 && y < 1000; }; // Test condition ANDed // with another predicate db3 = db.and(db2); System.out.println("81 is less than 100 " + db3.test(9)); db3 = db.or(db2); // Test condition ORed with another predicate System.out.println("49 is greater than 36" + " and less than 100 " + db3.test(7)); } } Output: 100 is less than 100 false 100 is greater than 100 false 81 is less than 100 true 49 is greater than 36 and less than 100 true Reference: https://docs.oracle.com/javase/8/docs/api/java/util/function/DoublePredicate.html Comment More infoAdvertise with us Next Article Java.util.function.IntPredicate 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.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 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 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.LongPredicate interface in Java with Examples The LongPredicate interface was introduced in JDK 8. This interface is packaged in java.util.function package. It operates on a long 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 LongPredicate M 2 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 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 Like