Enhanced for loop:
for (String element : array) {
// Do something with element of type String
System.out.println(element);
}
Традиционный для цикла: (
for (int i=0; i < array.length; i++) {
// Reference to the item in array[position]
String element = array[i];
// More code using String element
}
Взгляните на эти форумы: https://blogs.oracle. com / CoreJavaTechTips / entry / using_enhanced_for_loops_with
http://www.java-tips.org/java-se-tips/java.lang/the-enhanced-for-loop .html