这段代码有什么问题?
Set<String> A = new LinkedHashSet<String>();
Set<String> B = new LinkedHashSet<String>();
Set<String> C = new LinkedHashSet<String>();
// A and C are filled before the piece of code below:
for (String ce: A){
if (!C(ce))
B.add(ce);
}A中有一些字符串不在C中。因此,我希望B有一些元素,但当我打印它时,它总是空的。注意:在ArrayList中也会发生这种情况。
谢谢。
发布于 2018-12-11 21:54:51
正确的说明:
if(!C.contains(ce))我想检查A中的字符串是否不在LinkedHashSet C中。所有不在C中的字符串都应该添加到B中。谢谢。
https://stackoverflow.com/questions/53724813
复制相似问题