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 }