How to add multiple objects of class for same key value in HashMap in java?
<p>I want to store objects of class from arraylist to hashmap, one key may contain multiple objects, how to do that </p>

<p>here is my code,</p>

<p><code>Map&lt;Integer, classObject&gt; hashMap = new HashMap&lt;Integer, classObject&gt;();</code></p>

<pre><code>for(int i=0; i&lt;arraylist.size(); i++)
            {
                sortID = arraylist.get(i).getID();
                if(!hashMap.containsKey(sortID))
                {
                    hashMap.put(sortID, arraylist.get(i));
                }
                hashMap.get(sortID).add(arraylist.get(i)); //i got error in add method
            }
</code></pre>

<p>give any idea to add classobjects in hashmap for same key value...</p>
