DESKTOP-QT2JO23_20200907-孙中霞
一,问题
在理解写代码的过程中, collection的方法中removeAll(Collection<?> c)这部分不太理解,API文档中说是如果此 collection 包含指定 collection 中的所有元素,则返回 true,这个指定的collection是哪个,有些懵圈!我感觉自己写的有问题!
@Override
public boolean removeAll(Collection<?> c) {
final int old = count;
if (c instanceof Bags) {
Bags k = (Bags) c;
Object[] otherElemens = k.elements;
for (int i = 0; i < k.count; i++) {
Object a=otherElemens[i];
return this.removeAll(k);
}
}
return old != count;
}
二,吐糟
下午那会儿教室太热了!!! 在这个collection 的方法容易犯迷糊!
近期评论