I cannot find a simple way to find the sum of all keys within a ListMultiMap in Java.
I have a ListMultiMap:
ListMultimap<String, Long> foodCals = ArrayListMultimap.create();
That contains different keys with multiple values within them:
["19/03/2020": 77, 88, 88], ["18/03/2020": 22, 33, 21], ["17/03/2020": 77, 33, 88]
How do you find the total of each Key? And get an output like: 1-253 , 2-76, 3-198.
Something like this:
int p = 0;
for(String s : foodCals.keySet()){
System.out.Println(p + foodCals.sumOfKey(p)) //Print the index number + the sumOfKey (sumOfKey doesn't exist).
p++;
}