读书人

HashSet中迭代器的施用

发布时间: 2012-08-15 16:57:17 作者: rapoo

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

读书人网 >移动开发

热点推荐