Get repeated elements from list
<p>I need to get elements from database which repeat more than 3 times. Here is my code how I do this:</p>

<pre><code>    public static ArrayList&lt;Integer&gt; getPrice(List&lt;Integer&gt; list) {
    ArrayList&lt;Integer&gt; result = new ArrayList&lt;Integer&gt;();
    int val;
    HashMap&lt;Integer, Integer&gt; map = new HashMap&lt;Integer, Integer&gt;();
    for (int i = 0; i &lt; list.size(); i++) {
        val = list.get(i);
        if (!map.containsKey(val)) {
            map.put(val, 1);
        } else {
            map.put(val, map.get(val) + 1);
        }
    }
    for (Map.Entry&lt;Integer, Integer&gt; entry : map.entrySet()) {
        if (entry.getValue() &gt; 3) {
result.add(entry.getKey());
        }
    }
    return result;
}
</code></pre>

<p>Is it good and effective way?</p>
