Iterator itOfSys=hashSetOfSys.iterator();
Iterator itOfSelf=hashSetOfSys.iterator();
while(itOfSys.hasNext())//Iterator与cursor一样的读取模式
{
Object objectOfSys =itOfSys.next();
while(itOfSelf.hasNext())
{
Object objectOfSelf = itOfSelf.next();
if(objectOfSys.equals(objectOfSelf))//匹配到了,如果系统的包含自己的,说明不需要改变
{
break;
}
else//没有匹配到,说明系统有的,我们没有,需要被添加
{
listToBeAdd.add(objectOfSys);
}
objectOfSelf = null;
}
objectOfSys = null;
}
HashSet中迭代器的使用
最新推荐文章于 2023-09-12 07:22:06 发布