【发布时间】:2019-05-12 11:35:54
【问题描述】:
这段代码有什么问题?
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 也会发生这种情况。
谢谢。
【问题讨论】:
-
我不熟悉
if (!C(ce))的语法。这应该是做什么的?