码迷,mamicode.com
首页 > 其他好文 > 详细

双重Iterator 报错!!!!

时间:2017-05-24 18:32:48      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:ice   rem   turn   com   div   next   system   new   logs   

 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 报错!!!!

标签:ice   rem   turn   com   div   next   system   new   logs   

原文地址:http://www.cnblogs.com/chinazhou-wang/p/6900076.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!