import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList al = new ArrayList();
al.add(new Integer(1));
al.add(new Integer(2));
al.add(new Integer(3));
al.add(new Integer(4));
al.add(new Integer(5));
System.out.println("contents of al : " + al);
Object ia[] = al.toArray(); // get array
int sum = 0;
for (int i = 0; i < ia.length; i++){
sum += ((Integer) ia[i]).intValue();
}
System.out.println("Sum is :" + sum);
}
}