title: Can I use only HashMap?
body: <h1>Context</h1>
  
  <p>I've an object O with 4 primitive variables: </p>
  
  <ul>
  <li><p>a, b, c and d. (All 4 mandatory)</p></li>
  <li><p>The first 3 are keys, I used them to generate hashcode and equals. </p></li>
  <li><p>"d" is a counter, it begin from 1.</p></li>
  <li><p>I've an HashSet and a loop that insert O items, </p></li>
  <li><p>if HashSet contains a duplicate (key: a,b,c), I would modify the item O stored in HashSet to do d++ (otherwise I add the item to HashSet). </p></li>
  </ul>
  
  <p>But I can't get item from HashSet (HashSet doesn't have the .get method).</p>
  
  <h1>Question</h1>
  
  <p>So the only (and best) way to handle this is to make HashMap ?</p>
  
  <h1>My solution</h1>
  
  <pre><code>    class O {
         int a, b, c, d;
  
         boolean equals(Object o) { /* handle only a,b,c */ }
         int hashCode() { /* handle only a,b,c */ }
      }
  
  ...
  
  
          HashMap&lt;O, O&gt; group = new HashMap&lt;O, O&gt;();
          O curr = null;
  ...
              while (...) //Iterate the result set from a query where I can't use groupBy
              {
                  curr = new O();
                  curr.setA(...);
                  curr.setB(...);
                  curr.setC(...);
                  O ex = group.get(curr);
                  if (ex != null)
                  {
                      ex.setD(ex.getD()+1);
                  }
                  else
                  {
                      group.put(curr , curr);
                  }
              }
  </code></pre>