public class q2 {
String gid;
String cid;
String name;
String number;
String gz;
String gl;
public q2(String gid, String cid, String name, String number, String gz, String gl) {
this.gid = gid;
this.cid = cid;
this.name = name;
this.number = number;
this.gz = gz;
this.gl = gl;
}
public String getGid() {
return gid;
}
public void setGid(String gid) {
this.gid = gid;
}
public String getCid() {
return cid;
}
public void setCid(String cid) {
this.cid = cid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getNumber() {
return number;
}
public void setNumber(String number) {
this.number = number;
}
public String getGz() {
return gz;
}
public void setGz(String gz) {
this.gz = gz;
}
public String getGl() {
return gl;
}
@Override
public String toString() {
return "q2{" +
"gid='" + gid + '\'' +
", cid='" + cid + '\'' +
", name='" + name + '\'' +
", number='" + number + '\'' +
", gz='" + gz + '\'' +
", gl='" + gl + '\'' +
'}';
}
public void setGl(String gl) {
this.gl = gl;
}
}
private static void q1() {
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));
}
}
}