Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Java Arrays
  • Java Strings
  • Java OOPs
  • Java Collection
  • Java 8 Tutorial
  • Java Multithreading
  • Java Exception Handling
  • Java Programs
  • Java Project
  • Java Collections Interview
  • Java Interview Questions
  • Java MCQs
  • Spring
  • Spring MVC
  • Spring Boot
  • Hibernate
Open In App
Next Article:
Java.util.function.LongPredicate interface in Java with Examples
Next article icon

Java.util.function.DoublePredicate interface in Java with Examples

Last Updated : 22 Sep, 2021
Comments
Improve
Suggest changes
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
 



Next Article
Java.util.function.LongPredicate interface in Java with Examples

C

CharchitKapoor
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
  • Java.util.function.IntBinaryOperator interface with Examples
    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 encapsula
    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
  • 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
  • Double isInfinite() method in Java with examples
    The java.lang.Double.isInfinite() method of Java Double class is a built in method in Java returns true if this Double value or the specified double value is infinitely large in magnitude, false otherwise. Syntax: public boolean isInfinite() or public static boolean isInfinite(double val) Parameters
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences