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"}; // All candidatesString [] B = {"zhangsan, Chinese, 80 ","Zhangsan, English, 89 ",
"Lisi, mathematics, 69 ",
"Lisi, English, 99 ",
"Zhaoliu, mathematics, 78"}; // student transcript that has taken the test
// Which candidates are missing?
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); // The difference set of the Set
// Traverse the remaining elements in SA, that is, those who have not taken the test
Iterator<String> it = sa.iterator();
while(it.hasNext()){System.out.println(it.next());
}
}
}