-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLambdaBase.java
More file actions
37 lines (31 loc) · 870 Bytes
/
LambdaBase.java
File metadata and controls
37 lines (31 loc) · 870 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
package example.LambdaExpressExample;
import java.util.List;
import java.util.ArrayList;
/**
* Lambda 表達式
*
*
*
*
* Reference
* - https://mrbird.cc/java8lambda1.html -
* https://pdai.tech/md/java/java8/java8-stream.html
* - https://blog.tonycube.com/2015/10/java-java8-2-lambda-expression.html
*/
public class LambdaBase {
public static void main(String[] args) {
copyAndPrint();
}
public static void copyAndPrint() {
List<Integer> list = new ArrayList<Integer>();
List<Integer> list2 = new ArrayList<Integer>();
list.add(1);
list.add(133);
list.add(4);
list.forEach(list2::add);
list2.forEach(System.out::println);
// ! 不要在Lambda內修改定義在域外的變數
// list2.forEach((e -> { e++; }));
}
// TODO: stream, parallelStream
}