title: collections api in Java
body: <p>I have a method runningTotal that returns a new ArrayList that contains a running total of the original list. In other words, the i th value in the new list should store the sum of elements 0 through i of the original list. For example, if a variable list stores the following sequence of values:</p>
  
  <p>[2, 3, 5, 4, 7, 15, 20, 7]
  and the following call is made:</p>
  
  <p>System.out.println(runningTotal(list));
  Then the variable list should store the following sequence of values:</p>
  
  <p>[2, 5, 10, 14, 21, 36, 56, 63].</p>
  
  <p>I have a written a method,which I know is wrong.But I am looking for a hint to solve it on my own.Here is my code.Please provide hint,do not give me entire solution.</p>
  
  <pre><code>    public static List&lt;Integer&gt; runningTotal(List&lt;Integer&gt; list)
      {
          List&lt;Integer&gt; list2=new ArrayList&lt;Integer&gt;();
          //int sum=0;
          for(int i=0;i&lt;list2.size();i++)
              list2.add(list2.get(i)+list.get(i+1));
          return list2;
      }
  </code></pre>