-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConvertorTest.java
More file actions
97 lines (39 loc) · 1.21 KB
/
ConvertorTest.java
File metadata and controls
97 lines (39 loc) · 1.21 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package org.r00txx.tese;
import com.sun.javafx.collections.MappingChange;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class ConvertorTest {
public static void main (String[] args) {
testList2Array();
testArra2List();
testSet2List();
testList2Set();
testSet2Array();
testArray2Set();
testMap2Set();
testMap2List();
}
private static void testMap2List() {
Map<String, String> map = new HashMap<String, String>();
map.put("A", "ABC");
map.put("K", "KK");
map.put("L", "LV");
//将 map key 转化为 list
List<String> mapKeyList = new ArrayList<String>(map.keySet());
System.out.println("map key list: " + mapKeyList);
//将 map value 转化为 list
List<String> mapValueList = new ArrayList<String>(map.values());
System.out.println("map value list: " + mapValueList);
}
private static void testMap2Set () {
Map<String, String> map = new HashMap<String, String>();
map.put("A", "ABC");
map.put("K", "KK");
map.put("L", "LV");
//讲 map 的键转化为 set
Set<String> mapKeySet = map.keySet();
}
}