Given an array of integers say, 

```
integers[] = {1, 2, 1, 7, 2};

```

I plan to use the following code to return a Map with the array element as the key and the indexes of that element as the value. 

e.g., in this case, we will return:

```
1 -> (0,2)
2 -> (1,4)
7 -> (3)

```

But it does not quite work - the initial values added to the set aren't appearing. Here is the code:

```
Map<Integer, Set<Integer>> hm = new HashMap<>();
for ( int k=0; k<integers.length; k++) { 
    Integer key=integers[k]; 
    if (hm.containsKey(key))
        hm.get(key).add(k);
    else
        hm.put(key, new HashSet<Integer>(k));
}

```