forked from bjmashibing/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLambdaDemo.java
More file actions
37 lines (34 loc) · 1.04 KB
/
LambdaDemo.java
File metadata and controls
37 lines (34 loc) · 1.04 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
package com.mashibing;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
/**
* @author: 马士兵教育
* @create: 2019-10-13 16:22
*/
public class LambdaDemo {
public static void main(String[] args) {
// Thread thread = new Thread(new Runnable() {
// @Override
// public void run() {
// System.out.println("running.....");
// }
// });
// thread.start();
//
// new Thread(()->{System.out.println("running2.....");}).start();
List<String> list = Arrays.asList("java","javascript","scala","python");
// Collections.sort(list, new Comparator<String>() {
// @Override
// public int compare(String o1, String o2) {
// return o1.length()-o2.length();
// }
// });
// for(String str:list){
// System.out.println(str);
// }
Collections.sort(list,(a,b)->a.length()-b.length());
list.forEach(System.out::println);
}
}