zoukankan      html  css  js  c++  java
  • 双重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         }
  • 相关阅读:
    ASCII&Base64
    CentOS自动同步时间
    Java的HashMap
    Java线程同步操作
    Nginx基本配置与应用
    vc中调用Com组件的方法详解
    VC++ try catch (转)
    oracle中exp,imp的使用详解
    jdbc oracle 连接字符串
    标准的开源实现
  • 原文地址:https://www.cnblogs.com/chinazhou-wang/p/6900076.html
Copyright © 2011-2022 走看看