日期:2014-05-18 浏览次数:20679 次
public static void main(String[] args) {
String[] a = {"a", "b", "c"};
String[] b = {"c", "d"};
Set<String> sa = new HashSet<String>();
for (int i = 0; i < a.length; i++) {
sa.add(a[i]);
}
for (int j = 0; j < b.length; j++) {
sa.remove(b[j]);
}
Iterator<String> ia = sa.iterator();
while (ia.hasNext()) {
System.out.println(ia.next());
}
}
public static void removeData(String[] a, String[] b) {
Set set = new HashSet();
for (Object o : b) {
set.add(o);
}
for (int i = 0; i < a.length; i++) {
if (set.contains(a[i])) {
a[i] = null;
}
}
}