title: Possible to sum up object values in HashMap?
body: <p>I've just started using HashMaps in Java, and I was wondering if it's possible to sum up the object values in the HashMap. </p>
  
  <p>I've already done this using an ArrayList like so:</p>
  
  <pre><code>private int totalWeight() {
          int totalWeight = 0;
          for(Item item : items){
              totalWeight += item.getWeight();
          }
          return totalWeight;
      }
  </code></pre>
  
  <p>I have different objects with the value weight, and I'm trying to return the total value of the weight as totalWeight, but can't seem to do so using HashMap.</p>