Question: BiPredicateTest ( 3 0 ) Using the BiPredicate interface implement the following logical expression and demonstrate it . In main create a BiPredicate called biPred

BiPredicateTest (30)
Using the BiPredicate interface implement the following logical expression and demonstrate it.
In main create a BiPredicate called biPred that accepts two Integers and returns true if the first value is greater than 2.
Create a loop that tests going from 1 to 4 with an inner loop to test y from 1 to 4 inclusive
Call resultBi with a chained Predicate consisting of be (biPred and (y < x))negated and the two values x and y. Note that negate is applied to the entire chained predicate
Test for all combination from 1 to 4 inclusive.
The method resultBi accepts a BiPredicate and two values, all of type T.
Use the test method of the predicate and print out the results below.
Sample output:
The BiPredicate is true for values 1 and 1
The BiPredicate is true for values 1 and 2
The BiPredicate is true for values 1 and 3
The BiPredicate is true for values 1 and 4
The BiPredicate is true for values 2 and 1
The BiPredicate is true for values 2 and 2
The BiPredicate is true for values 2 and 3
The BiPredicate is true for values 2 and 4
The BiPredicate is false for values 3 and 1
The BiPredicate is false for values 3 and 2
The BiPredicate is true for values 3 and 3
The BiPredicate is true for values 3 and 4
The BiPredicate is false for values 4 and 1
The BiPredicate is false for values 4 and 2
The BiPredicate is false for values 4 and 3
The BiPredicate is true for values 4 and 4
Using Predicate:
public static void result(Predicate p, T arg)
{
if (p.test(arg))
System.out.printf("The Predicate is true for %s
", arg);
else
System.out.printf("The Predicate is false for %s
", arg);
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!