谁能说出这个统计方法中,remove(int i)与 remove(Object obj)的区别?
// 统计
public ArrayList summaryList(ArrayList arrayList, String Name) {
ArrayList resultList = new ArrayList();
while (arrayList.size() > 1) {
HashMap hm1 = (HashMap) arrayList.get(0);
String totalAmount = "0";
String totalconvertAmount = "0";
for (int ii = 1; arrayList.size() > ii;) {
HashMap hm2 = (HashMap) arrayList.get(ii);
String key1 = (String) hm1.get(Name);
String key2 = (String) hm2.get(Name);
String cur1 = (String) hm1.get("Currency");
String cur2 = (String) hm2.get("Currency");
if (key1.hashCode() == key2.hashCode() && cur1.hashCode() == cur2.hashCode()) {
BigDecimal temp1 = new BigDecimal(0);
BigDecimal temp2 = new BigDecimal(0);
String sum1 = (String) hm1.get("Amount");
String sum2 = (String) hm2.get("Amount");
String sum3 = (String) hm1.get("ConvertRMB");
String sum4 = (String) hm2.get("ConvertRMB");
BigDecimal a = new BigDecimal(sum1);
BigDecimal b = new BigDecimal(sum2);
BigDecimal c = new BigDecimal(sum3);
BigDecimal d = new BigDecimal(sum4);
temp1 = temp1.add(a);
temp1 = temp1.add(b);
temp2 = temp2.add(c);
temp2 = temp2.add(d);
totalAmount = temp1.toString();
totalconvertAmount = temp2.toString();
hm1.put("Amount", totalAmount);
hm1.put("ConvertRMB", totalconvertAmount);
arrayList.remove(hm2);//与arrayList.remove(ii);的区别?
continue;
}
ii++;
}
resultList.add(hm1);
arrayList.remove(hm1);//与arrayList.remove(0);的区别?
}
if (arrayList.size() == 1) {
resultList.add(arrayList.get(0));
}
return resultList;
}