Finding how many times an item has appeared in an array = explaining the code : <p>Could you please explain how does this code work ? 
I can not understand how this code works. </p>

<pre><code>        HashMap&lt;String, Integer&gt; countMap = new HashMap&lt;String, Integer&gt;();
        for (String string : strArray) {
            if (!countMap.containsKey(string)) {
                countMap.put(string, 1);
            } else {
                Integer count = countMap.get(string);
                count = count + 1;
                countMap.put(string, count);
            }
        }
        printCount(countMap);
    }


    private static void printCount(HashMap&lt;String, Integer&gt; countMap) {
        Set&lt;String&gt; keySet = countMap.keySet();
        for (String string : keySet) {
            System.out.println(string + " : " + countMap.get(string));
        }
    }
}
</code></pre>
