谁能说出这个统计方法中,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;
}
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;
}
...全文
相关推荐
C# Array和ArrayList,List区别
C# Array和ArrayList,List区别
java for循环与增强for循环
增强型的for循环 和普通for循环一样 增强型的for循环 优点主要体现在集合中,随便举个例子 比如对 set 的遍历 一般是迭代遍历
详解Java中的增强 for 循环 foreach
foreach 是 Java 中的一种语法糖,几乎每一种语言都有一些这样的语法糖来方便程序员进行开发,编译期间以特定的字节码或特定的方式来对这些语法进行处理。能够提高性能,并减少代码出错的几率。
Java开发中的容器概念、分类与用法深入详解
主要介绍了Java开发中的容器概念、分类与用法,结合实例形式较为详细的分析了java容器的相关概念、分类、使用方法与注意事项,需要的朋友可以参考下
C#自建类实现集合接口IEnumerable, IEnumerator
C#自建集合类MyArrayList实现集合接口IEnumerable, IEnumerator, 实现方法 inr add(object value),void Remove(object o), int Count, void Clear()


Java SE
