-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMyTest.java
More file actions
49 lines (35 loc) · 881 Bytes
/
Copy pathMyTest.java
File metadata and controls
49 lines (35 loc) · 881 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
40
41
42
43
44
45
46
47
48
package com.fancv;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class MyTest {
public static void main(String[] args) {
List<mydto> mydtoList= new ArrayList<>(2);
mydto a = new mydto();
a.setId(102L);
a.setName("a");
mydto b = new mydto();
b.setId(101L);
b.setName("a");
mydtoList.add(a);
mydtoList.add(b);
Map<String,Long> d =mydtoList.stream().collect(Collectors.toMap(mydto::getName,mydto::getId));
}
}
class mydto {
private String name;
private Long id;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}