Java examples: Enhanced For Loop


public static void enhancedForLoop(){
int[] arr = {1, 2, 3, 4, 5, 6, 7, 8, 9};
System.out.println("\nEXAMPLE: Enhanced For Statement");
for (int temp: arr){ // Create a temporary variable, same type as array values. For
// loop assign array value to the temporary variable
System.out.println("Enhanced = " + temp);
}
}