[项目bug收集整理4]list removeAll方法

项目中有这样一段代码:

List<MyClass> aList = this.xxService.getList();

List<MyClass> bList = this.xxService.getOtherList();

aList.removeAll(bList);

发现无法实现删除。

后来发现 原来removeAll在实现时,会比较两个对象的所有域是否相同。除非自己实现了hashCode,equals方法来明确只要哪些项相等就认为相等才可以删除。

 

很想看看removeAll的源码。。。

posted @ 2013-12-01 21:49  akingseu  阅读(548)  评论(0编辑  收藏  举报