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
- test(): This function evaluates a conditional check on the long value, and returns a boolean value denoting the outcome.
boolean test(long value)
- and(): This function applies the AND operation on the current object and the object recieved as argument, and returns the newly formed predicate. This method has a default implementation.
default LongPredicate and(LongPredicate other)
- negate(): This function returns the inverse of the current predicate i.e reverses the test condition. This method has a default implementation.
default LongPredicate negate()
- or(): This function applies the OR operation on the current object and the object recieved as argument, and returns the newly formed predicate. This method has a default implementation.
default LongPredicate or(LongPredicate other)
499999 is equal to 500000 false 499999 is less than equal to 500000 true 500000 is equal to 500000 true 500001 is less than equal to 500000 false 499999 is greater than 500000 false
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.