更新时间:2022-12-12 19:18:38
您正在将Map
的条目添加到原始List
中.您应该先清除它们:
You are adding the entries of the Map
to the original List
s. You should clear them first:
nameArray.clear();
priceArray.clear();
for (Map.Entry<String, BigDecimal> entry : totals.entrySet()) {
nameArray.add(entry.getKey());
priceArray.add(entry.getValue());
}
或者,如果您不想覆盖原始的List
,则应创建新的ArrayList
.
Or, if you don't want to overwrite the original List
s, you should create new ArrayList
s.