Java for-each loop
Java for-each loop
Java provides an enhanced for loop to traverse the data structures like array or collection. In the for-each loop, we don't need to update the loop variable. The syntax to use the for-each loop in java is given below.
Consider the following example to understand the functioning of the for-each loop in Java.
ForEachTest.java
Output:
Printing the content of the array names: Rahul
Nirmal
Siva
Deepak
Rani
Comments
Post a Comment