首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

HashSet中迭代器的施用

2012-08-15 
HashSet中迭代器的使用Iterator itOfSyshashSetOfSys.iterator()Iterator itOfSelfhashSetOfSys.iterat

HashSet中迭代器的使用

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;}
?

热点排行