title: how to add variable to array list and then total all the elements of arraylist?
body: <p>I'm trying to input a variable into an ArrayList and then add all the elements. How can i do that? The code I tried is below.  Thanks.</p>
  
  <pre><code>ArrayList&lt;String&gt; aListNumbers = new ArrayList&lt;String&gt;();
  int abc = 23;
  aListNumbers.add("abc");
  aListNumbers.add("2");
  aListNumbers.add("3");
  
  //Java ArrayList Sum All Elements
  
  int sum = 0;
  for(int i=0; i &lt; aListNumbers.size(); i++){
      sum = sum + Integer.parseInt(aListNumbers.get(i));
  }
  
  System.out.println("Sum of all elements of ArrayList is " + sum);
  </code></pre>