第二次作业
import java.util.*;
public class Demo01 {
public static void main(String[] args) {
show01();
}
private static void show01() {
Map<String, ArrayList<Person>> map1 = new HashMap<>();
Map<String, ArrayList<Person>> map2 = new HashMap<>();
Map<String, ArrayList<Person>> map3 = new HashMap<>();
ArrayList<Person> arr = new ArrayList<>();
Collections.addAll(arr, new Person("W1", "WS1", "Chisel", "13024390423", "special", "5"),
new Person("W2", "WS1", "Asa", null, "expert", null),
new Person("W3", "WS1", "Parker", "15754183291", "common", "1"),
new Person("W4", "WS1", "Ron", "18283957359", "common", "0"),
new Person("W5", "WS1", "Tyler", null, "common", "0"),
new Person("W6", "WS1", "Tony", "17683934639", " common", " 0"),
new Person("W7", "WS1", "August", null, "common", "0"),
new Person("W8", "WS2", "Sam", "13186396347", "special", "5"));
for (Person person : arr) { //遍历数组
if (map1.get(person.getCid()) == null) {
map1.put(person.getCid(), new ArrayList<Person>());
}
map1.get(person.getCid()).add(person);
}
Set<String> strings = map1.keySet();
for (String string : strings) {
System.out.println(string + map1.get(string));
}
}
}