package cn.cqu.huang;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public class SetDemo {
public static void main(String[] args) {
String[] a = {"ZhangSan","LiSi","WangWu","ZhaoLiu","QianQi"};//所有考生
String[] b = {"ZhangSan,语文,80",
"ZhangSan,英语,89",
"LiSi,数学,69",
"LiSi,英语,99",
"ZhaoLiu,数学,78"};//已经参加考试的学生成绩单
//求哪些考生缺考
Set<String> sa = new HashSet<String>();
for(int i=0;i<a.length;i++){
sa.add(a[i]);
}
Set<String> sb = new HashSet<String>();
for(int i=0;i<b.length;i++){
sb.add(b[i].split(",")[0]);
}
sa.removeAll(sb); //集合的差集
//遍历sa中剩下的元素,也即未参加考试的考生
Iterator<String> it = sa.iterator();
while(it.hasNext()){
System.out.println(it.next());
}
}
}