The enhanced for statement allows you to iterate through the elements of an array or a collection without using a counter. Give an example. Notice: The enhanced for statement cannot be used to modify elements in an array. If a program needs to modify elements, use the traditional counter-controlled for statement.

Respuesta :

Answer:

Check the explanation

Explanation:

public class EnhancedForExample {

   public static void main(String[] args) {

       int[] arr = {4, 2, 9, 1, 5, 7};

       for(int num : arr) {

           System.out.println(num);

       }

   }

}

Kindly check the attached image below for the code output.

Ver imagen temmydbrain

Answer:

See explaination

Explanation:

public class EnhancedForExample

{

public static void main(String[] args) {

int[] arr = {3, 5, 9, 4, 5, 9};

for(int num : arr) {

System.out.println(num);

}

}