title: Add each element of an ArrayList to each element of another ArrayList
body: <p>I have an ArrayList which has N items. I want to iterate through the ArrayList, and add each item in the ArrayList to the equivalent item in another ArrayList. I have tried this, but it doesn't work:</p>
  
  <pre><code>ArrayList&lt;Integer&gt; arrList1 = new ArrayList&lt;Integer&gt;();
  
  for(String key: myMap.keyValues() {
      ArrayList&lt;Integer&gt; dynArrList = getArrayListFromSomewhereElse();
  
      for(Integer i : dynArrList) {
         arrList1.set(i, arrList1.get(i) + dynArrList.get(i)); // sum each item
      }
  }
  </code></pre>
  
  <p>I get index out of bounds exception. I have tried to initilise arrList1, but it made no difference. I also tried to set a minimum size for it.</p>