-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainPredicate.java
More file actions
36 lines (23 loc) · 1.2 KB
/
MainPredicate.java
File metadata and controls
36 lines (23 loc) · 1.2 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
package examples;
public class MainPredicate {
public static void main(String[] args) {
Predicate<String> p1 = (s) -> s.length() < 20;
Predicate<String> p2 = (s) -> s.length() > 5;
boolean b = p1.test("Hello");
System.out.println("Hello is shorter than 20 chars " + b);
Predicate<String> p3 = p1.and(p2);
System.out.println("On Yes: " + p3.test("Yes"));
System.out.println("Good Morning: " + p3.test("Good Morning"));
System.out.println("Good Morning gentlemen: " + p3.test("Good Morning Gentlemen"));
Predicate<String> p4 = p1.or(p2);
System.out.println("On Yes: " + p4.test("Yes"));
System.out.println("Good Morning: " + p4.test("Good Morning"));
System.out.println("Good Morning gentlemen: " + p4.test("Good Morning Gentlemen"));
Predicate<String> p5 = Predicate.isEqualsTo("Yes");
System.out.println("On Yes: " + p5.test("Yes"));
System.out.println("On No: " + p5.test("No"));
Predicate<Integer> p6 = Predicate.isEqualsTo(1);
System.out.println("On 1: " + p6.test(1));
System.out.println("On 2: " + p6.test(2));
}
}