import java.util.*;
public class Arraylistcollection
{
ArrayList<Integer> list = new ArrayList<Integer>();
Public static void main (String args[])
{
//Numberinglist(list);
int total = 0;
Iterator<Integer> iter = list.iterator();
while (iter.hasNext())
{
Integer val = iter.next();
total = total + val;
}
System.out.println("The total Amount is" +total);
}
private static void Numberinglist(ArrayList<Integer> list)
{
list.add(new Integer(1));
list.add(new Integer(2));
}
}
--- Update ---
Sorry
Numberinglist(list); is not commented.
it is still throwuing an error on the opening braces to Public static void main(String args[]);
--- Update ---
Error is:
Compilation Errors Detected
Line: 6
<identifier> expected