Exercise 4.5: Java - Writing a Method to Reduce Word Counts in HashMaps
Write a method called "reduce" in Java, which takes in two HashMap<String, Integer> objects. Each HashMap contains the word count of a separate piece of a single document. The keys are words that were found in that piece of the document, and the value for each key is the number of times that word occurred in the piece of the document. This method's output is a single HashMap, which contains the word counts of both maps combined.
For example, if the inputs are:
["aiko": 2, "fluffy": 5, "zugzwang": 10]
and
["fluffy": 1, "aiko": 5, "panda": 2222]
the output should be:
["fluffy": 6, "zugzwang": 10, "aiko": 7, "panda": 2222]