首页 > 代码库 > 双重Iterator 报错!!!!
双重Iterator 报错!!!!
1 List list = new ArrayList(); 2 list.add(new String[]{"0","s1","0038","45"}); 3 list.add(new String[]{"0","s2","0038","45"}); 4 list.add(new String[]{"0","s3","0039","45"}); 5 list.add(new String[]{"0","s4","0039","45"}); 6 list.add(new String[]{"0","s5","0039","45"}); 7 Iterator iter = list.iterator(); 8 Iterator iterCompare = list.iterator(); 9 String office_code = ""; 10 String turnId = ""; 11 double money = 0.00; 12 while(iter.hasNext()){ //去掉某个元素只能调用iter.remove()方法。 13 String[] str = (String[]) iter.next(); 14 if("".equals(office_code)){ 15 office_code = str[2]; 16 while(iterCompare.hasNext()){ 17 String[] strCompare = (String[]) iterCompare.next(); 18 if(office_code.equals(strCompare[2])){ 19 money += Double.parseDouble(str[6]); 20 iterCompare.remove(); 21 } 22 } 23 //数据库操作 24 System.out.println(str); 25 money = 0.00;//初始化金额 26 } 27 28 if(office_code.equals(str[2])){//主数据存在就删除 29 iter.remove(); 30 continue; 31 } 32 office_code = "";//要汇总的数据删除完后 33 }
双重Iterator 报错!!!!
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。