title: Storing multiple values with same key in HashMap
body: <p>I had an interview today and my interviewer asked me that how can I store multiple values having the same key in HashMap?
  She gave me this example-->If I am given a list of String and I am suppose to store the length of String as key and the String itself as value.</p>
  
  <p>I gave her the following solution in how I will be using HashMap: </p>
  
  <pre><code>Map&lt;Integer, ArrayList&lt;String&gt;&gt; map = new HashMap&lt;Integer, ArrayList&lt;String&gt;&gt;();
  </code></pre>
  
  <p>Integer being the length of the String and the ArrayList will store the Strings of that particular length. </p>
  
  <p>The interviewer said that this is one way of using the HashMap but there is another way in which I won't be requiring ArrayList or any other data structure. During interview, I couldn't come up with any solution and now after enough googling, I still have nothing. Can anyone tell me how can I achieve the solution to this question?</p>
  
  <p>Thanks!</p>