How do I add values to a Set inside a Map?

dictionary, hashmap, java, key, set

Solution

Not difficult if I understand correctly.

Map<String, Set<Integer>> reqdMap = new HashMap<String, Set<Integer>>();

//Form the set corresponding to apple.
Set<Integer> appleSet = new HashSet<Integer>();
appleSet.add(1);
...


reqdMap.put("apple", appleSet);

//To Retrieve
appleSet = reqdMap.get("apple");

Problem

I have this map `Map<String, Set<Integer>> myMap;`, now I need to interact with it, how do I do it? for example: Keys are: "apple", "orange", "grape", etc. Each set will contain random numbers: 1-9 I need to create a Map (HashMap or TreeMap) that has Strings for keys and sets for the values. I need to return the set given a key. I also need to be able to fill each set with multiple numbers based on a key. Not sure how to approach this problem. Any thoughts?

Original source