TheBrahminCoder - How to Implement For each Loop in Java
In Java , The "for each" loop is also know as the "enhanced for loop". It is used to iterate over an array or a collection of objects.Here is an example:
this will output:
In this example,the for each loop is used to iterate over an array of strings. The variable fruit takes on the value of each string in the array, one at a time.The System.out.println() function is called once for each string in the array, with the value of fruit as a parameter.
Comments
Post a Comment