title: How can a HashMap consist only of one entry/object?
body: <p>I would like to have a <code>HashMap</code> with only one key-value object.</p>
  
  <p>I have created the following <code>HashMap</code>:</p>
  
  <pre><code>    HashMap &lt;Integer,String&gt;DocsCollection = new HashMap &lt;Integer,String&gt;();
  </code></pre>
  
  <p>In the HashMap I would like to have only one entry/object.
  The key type is an Integer.
  The value type is a String.</p>
  
  <blockquote>
    <p>e.g.  = &lt;1,"foo.txt"> </p>
  </blockquote>
  
  <p>Every time I find a specific word in a file I would like to</p>
  
  <ol>
  <li><p>Increment the counter in key</p></li>
  <li><p>Add the new file in the value</p></li>
  </ol>
  
  <p>e.g. Let's say that I'm searching for the word "Hello" in a <code>DocsCollection</code>,
  I have to store for every appearance of the word "Hello" the term frequency and concatenate the new file to the previous value.</p>
  
  <blockquote>
    <p>&lt;3,"foo.txt,hello.txt,test.txt"> </p>
  </blockquote>
  
  <p>3 means that I've found the word "Hello" in three files.</p>
  
  <p>and the Value consists of the files where the word was found</p>
  
  <p>If I use the method put, a new entry is created in the <code>HashMap</code> cause the key changes.
  It's not stable. It begins with "1" but when I find the word second time , the key increments and then the put method inserts a new entry with a new key
  But i would like to have only one entry and modify the key.
  Can this be done?
  How can i have only one object in a HashMap and modify the key every time?</p>
  
  <pre><code>   DocsCollection.put(2,"foo.txt,hello.txt"); 
  </code></pre>
  
  <p>Thanks, in advance</p>