How do I sum up all the values which are in two different maps?
Map<String, List<String>> map = new HashMap<String, List<String>>();
List<String> totalValOne= new ArrayList<String>();
List<String> totalValTwo= new ArrayList<String>();
map1.put("totalPriceSet1", totalValOne);
map2.put("totalPriceSet2", totalValTwo);
I'm getting all the values
String PriceValues1 = "";
for (int i = 0; i < map1.size(); i++) {
System.out.println(map1.size());
for (List<String> value : map1.values()) {
for (String tot : value) {
PriceValues1 = tot;
System.out.println("values..... "+ tot);
}
}
//--------
String PriceValues2 = "";
for (int i = 0; i < map2.size(); i++) {
System.out.println(map2.size());
for (List<String> value : map2.values()) {
for (String tot : value) {
PriceValues2 = tot;
System.out.println("values..... "+ tot);
}
}
I am trying to add the values of both the maps one by one.
ex:
totalPriceSet1 {1,2,3,4}
totalPriceSet2 {2,3,4,5}
and I want the sum of the two as,
Sum {3,5,7,9}