Java.util.function.IntPredicate interface in Java with Examples Last Updated : 13 Aug, 2021 Comments Improve Suggest changes Like Article Like Report 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 Methods: test(): This function evaluates a conditional check on the int value, and returns a boolean value denoting the outcome. boolean test(int value) 2. 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 IntPredicate and(IntPredicate other) 3. negate(): This function returns the inverse of the current predicate i.e reverses the test condition. This method has a default implementation. default IntPredicate negate() 4. 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 IntPredicate or(IntPredicate other) Example: Java // Java example to demonstrate IntPredicate interface import java.util.function.IntPredicate; public class IntPredicateDemo { public static void main(String[] args) { // Predicate to check a value is less than 544331 IntPredicate intPredicate = (x) -> { if (x <= 544331) return true; return false; }; System.out.println("544331 is less than 544331 " + intPredicate.test(544331)); // Predicate to check a value is equal to 544331 IntPredicate predicate = (x) -> { if (x == 544331) return true; return false; }; System.out.println("544331 is equal to 544331 " + predicate.test(544331)); // ORing the two predicates IntPredicate intPredicate1 = intPredicate.or(predicate); System.out.println("544331 is less than equal to 544331 " + intPredicate1.test(544331)); // ANDing the two predicates intPredicate1 = intPredicate.and(predicate); System.out.println("544331 is equal to 544331 " + intPredicate1.test(544331)); // Negating the predicate intPredicate1 = intPredicate.negate(); System.out.println("544331 is greater than 544331 " + intPredicate1.test(544331)); } } Output: 544331 is less than 544331 true 544331 is equal to 544331 true 544331 is less than equal to 544331 true 544331 is equal to 544331 true 544331 is greater than 544331 false Reference: https://docs.oracle.com/javase/8/docs/api/java/util/function/IntPredicate.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.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.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.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 8 | IntToDoubleFunction Interface in Java with Examples The IntToDoubleFunction 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 an int-valued argument and gives a double-valued result. The lambda expression assigned to an obj 1 min read Java 8 | IntToLongFunction Interface in Java with Examples The IntToLongFunction 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 an int-valued argument and gives a long-valued result. The lambda expression assigned to an object 1 min read IntFunction Interface in Java with Examples The IntFunction 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 an int-valued argument and produces a result of type R. This functional interface takes in only one gener 1 min read Java 8 | IntSupplier Interface with Examples The IntSupplier 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 any argument but produces an int value. The lambda expression assigned to an object of IntSupplier t 1 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 ToIntFunction Interface in Java with Examples The ToIntFunction 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 an argument of type T and produces an int-valued result. This functional interface takes in only one ge 1 min read Like