-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlambdaTest.java
More file actions
39 lines (29 loc) · 978 Bytes
/
lambdaTest.java
File metadata and controls
39 lines (29 loc) · 978 Bytes
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
38
39
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;
public class lambdaTest {
public static void main(String[] args) {
example1();
example2();
}
public static void example1() {
new Thread(() -> System.out.println("this is first example")).start();
}
public static void example2() {
List<String> features = Arrays.asList("aaaaa", "bbbbbb", "cccccccc");
features.forEach(f -> System.out.println(f));
features.forEach(System.out::println);
}
public static void example3() {
List names = Arrays.asList("aaaa", "bbbbb", "cccccc", "dddd");
filter(names, (str)->str.startsWith("a"));
}
public static void filter(List<String> names, Predicate condition) {
for (String name: names) {
if (condition.test(name)) {
System.out.println(name + " ");
}
}
}
}