Check out example codes for "java for each loop". It will help you in understanding the concepts better.

Code Example 1

//itemset contains variables of type <Data Type>
for(<Data Type> item : itemset) {
  //loop
}

Code Example 2

// definition eine Datenstruktur, hier ein Array mit 9 Werten
int[] array = new int[]{4, 8, 4, 2, 2, 1, 1, 5, 9};

// ForEach Schleife
for( int k: array )
{
	System.out.println("k = "+k);
}

Code Example 3

for(int i : alist)
{
  i+=1
}

Code Example 4

for (int i=0; i<arr.length; i++) 
{ 
    type var = arr[i];
    statements using var;
}

Code Example 5

for (int i : array) { 
    System.out.println(i);
}

Code Example 6

// Java Program Demonstrate forEach() 
// method of ArrayList 
  
import java.util.*; 
public class GFG { 
  
    public static void main(String[] args) 
    { 
        // create an ArrayList which going to 
        // contains a list of Numbers 
        ArrayList<Integer> Numbers = new ArrayList<Integer>(); 
  
        // Add Number to list 
        Numbers.add(23); 
        Numbers.add(32); 
        Numbers.add(45); 
        Numbers.add(63); 
  
        // forEach method of ArrayList and 
        // print numbers 
        Numbers.forEach((n) -> System.out.println(n)); 
    } 
}

Learn ReactJs, React Native from akashmittal.com