-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathques2.java
More file actions
37 lines (32 loc) · 1.12 KB
/
ques2.java
File metadata and controls
37 lines (32 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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));
}
}