/**
*Output:
Original contents of vals: 1 2 3 4 5
Sum of values: 15
*/
import java.util.ArrayList;
public class MainClass {
public static void main(String args[]) {
ArrayList vals = new ArrayList();
vals.add(1);
vals.add(2);
vals.add(3);
vals.add(4);
vals.add(5);
System.out.print("Original contents of vals: ");
for (int v : vals)
System.out.print(v + " ");
System.out.println();
int sum = 0;
for (int v : vals)
sum += v;
System.out.println("Sum of values: " + sum);
}
}