Код: Выделить всё
HashMap map1;
HashMap map2; ...
И я хочу достичь этого без потери данных.
Пример:
Код: Выделить всё
map1 has entries: {, , }
< /code>
map2 has entries: {, , }
< /code>
mergedMap: {, , }
< /code>
I have tried this:
ArrayList listHashMap = new ArrayList();
HashMap mergedMap = new HashMap();
for(HashMap map: listHashMap) {
mergedMap.putAll(map);
}
< /code>
But I've understood that the values mapped to the same key would be replaced (put
Что я могу сделать, чтобы сложить каждое значение, отображенное с одной и той же ключом?
Подробнее здесь: https://stackoverflow.com/questions/722 ... nto-a-sing