title: How to store multiple objects from a hashmap that has the same key?
body: <p><strong>EDIT</strong></p>
  
  <p>I've tried this <a href="https://stackoverflow.com/questions/4956844/hashmap-with-multiple-values-under-the-same-key">HashMap with multiple values under the same key</a>, and my hashMap now looks like this <code>HashMap&lt;String, List&lt;Place&gt;&gt; placeMap = new HashMap&lt;&gt;();</code></p>
  
  <p>Also tried to put Object instead of Place(place is my superclass). But when I now create my subclasses and wants to add them to the HashMap I get: </p>
  
  <blockquote>
    <p>The method put(String, List) in the type <code>HashMap&lt;String,List&lt;Place&gt;&gt;</code> is not applicable for the arguments (String, NamedPlace)</p>
  </blockquote>
  
  <p>and </p>
  
  <blockquote>
    <p>The method put(String, List) in the type <code>HashMap&lt;String,List&lt;Place&gt;&gt;</code> is not applicable for the arguments (String, DescPlace)</p>
  </blockquote>
  
  <p>here is my adding which created the error: </p>
  
  <pre><code>NamedPlace p = new NamedPlace(x,y,answer,col,cat);
                  placeMap.put(answer, p);
  </code></pre>
  
  <hr>
  
  <pre><code>DescPlace dp = new DescPlace(x,y,answer, desc, col, cat);
                  mp.add(dp);
                  placeMap.put(answer, dp);
  </code></pre>
  
  <p>NamedPlace and DescPlace are both subclasses to Place, and I want them both in the same HashMap..</p>
  
  <p><strong>OP</strong></p>
  
  <p>I'm working on a little project here. The thing is that I need to use a HashMap instead of a ArrayList on this part of the project because HashMap is alot faster for searching. I've created a HashMap like this:</p>
  
  <pre><code>HashMap&lt;String, Object&gt; placeMap = new HashMap&lt;&gt;(); 
  </code></pre>
  
  <p>The String is the name of the Object, but the thing is that more than one object can have the same name. So I search for a object in my searchfield and I want to store all those objects that has that name into an ArrayList so I can change info in just them.</p>
  
  <p>The object have alot of different values, like name, position, some booleans etc.</p>
  
  <p>Do I need to create a HashCode method into my object class which shall create a unique hashcode?</p>