谁能说出这个统计方法中,remove(int i)与 remove(Object obj)的区别?

anchor anchor 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
// 统计
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;
}
...全文

相关推荐

评论 9
收藏 已收藏
分享
返回顶部
anchor
Java SE 62,621 成员 307,251 内容