Java: Enhanced For Statement
Enhanced for statements are very useful in java, especially when dealing with arrays.
Like a for loop they use the for keyword.
This is an example of an enhanced for statement in action:
int[] myarray = {9, 10, 11, 12, 13};
for (int item : myarray) {
System.out.println("Count: " + item);
}
The above example would output the numbers 9 to 13.
This is because the for statement goes through one by one all of the peices of the array, the values of these pieces are stored in the variable you specify in the parameters (in this case item).
These statements make it a whole lot easier to deal with arrays, as we don't have to mess about with the array length etc..
Back to Java

