问题:
读取一个文本文件,用逗号分隔,拿到一个String类型的name1List,从数据库表中拿到的一个name2List
然后用数据库表中的nameList2.removeAll(name1List),应该输出name2List的结果是去掉name1List后的所有name,但是英文的可以remove掉,中文确不行,在后台打印name的值,中文并没有乱码问题,还请高手帮忙。
读取一个文本文件,用逗号分隔,拿到一个String类型的name1List,从数据库表中拿到的一个name2List
然后用数据库表中的nameList2.removeAll(name1List),应该输出name2List的结果是去掉name1List后的所有name,但是英文的可以remove掉,中文确不行,在后台打印name的值,中文并没有乱码问题,还请高手帮忙。
public boolean removeAll(Collection<?> c) {
boolean modified = false;
Iterator<?> e = iterator();
while (e.hasNext()) {
if (c.contains(e.next())) {
e.remove();
modified = true;
}
}
return modified;
}原来在AbstractCollection里面
我先理解理解
if (elem == null) {
for (int i = 0; i < size; i++)
if (elementData[i]==null)
return i;
} else {
for (int i = 0; i < size; i++)
if (elem.equals(elementData[i]))
return i;
}
return -1;
}