title: How to sum elements from a Key List using ListMultimap from Guava
body: <h1><strong>Example:</strong></h1>
  <p>I want to <strong>sum</strong> the elements inside every key, which is basically an ArrayList of elements &quot;double numbers&quot;.The <em>Guava ArrayListMultimap</em> is declared in this way:
  <br /></p>
  <pre><code>ListMultimap &lt;String, Double&gt; multimap = LinkedListMultimap.create(); 
  </code></pre>
  <p>and displayed like this &quot;3 keys of ArrayList&quot;: <br /></p>
  <pre><code>HH_0=[0.1, 0.4, 0.2, 0.3, 0.1], 
  HH_1=[0.1,0.2], 
  HH_2=[0.1] 
  </code></pre>
  <p>The summation should be stored in an array or any simple structure like this output: <br /></p>
  <pre><code>array_sum=[1.1,0.3,0,1]
  </code></pre>
  <p>the actual size of <em>multimap</em> is <strong>8</strong> and not <strong>3</strong> because if any key has more than one value in its arraylist, means the key is duplicate and that's reason of using <em>multimap</em> of <em>Guava</em> , it can store duplicated keys with multiple (different or same) values in an <em>ArrayList</em> with the contrary in case of a simple <em>Hashmap.</em> <br /></p>
  <p><strong>My essay:</strong><br />
  I extracted the keys in <em>array_Str</em> of <em>Strings</em> to compare with. We suppose the length of the wanted <em>array_sum[ ]</em>  is already initiated with 3: <br /></p>
  <pre><code>double sum = 0.0;
  String array_Str = {&quot;HH_0&quot;,&quot;HH_1&quot;,&quot;HH_2&quot;};
  
         for (int i = 0; i &lt; array_sum.length; i++) {
             for (Entry&lt;String, Double&gt; entry : multimap.entries())  {
                 
                 
             if( entry.getKey().equals(array_sum[i])) {
                 
                 sum=sum+ entry.getValue();
             }
                 
             }
             array_sum[i]=sum;   
         }
  </code></pre>
  <p>Any guidance is very appreciated.</p>