Lecture 14
5
New for syntax works with arrays too
•zamples.com/JspExplorer/samples/     samplesJDK1_5.html
•
•
•
•
•But note how this code violates our conventions
–we require int[] array
–braces should surround one line for loop body
int array[] = {1, 2, 3, 4};
int sum = 0;
for (int e : array) 
    sum += e;
System.out.println(sum);