//for (type variable_name:array)
//The type must be compatible with the array type.
publicclass MainClass {
publicstaticvoid main(String[] argv) {
float[] floats = newfloat[] { 1.2F, 2.3F, 3.4F };
float sum = 0;
for (float f : floats)
sum += f;
System.out.println(sum);
}
}
6.9
5.4.enhanced for loop
5.4.1.
Enhanced for Loops and array: perform identical processing on every element of an array.