java foreach

Java
// 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)); 
    } 
} 
for (String name : names) {
    System.out.println(name);
}List<String> someList = new ArrayList<String>();
// add "monkey", "donkey", "skeleton key" to someList
for (String item : someList) {
    System.out.println(item);
}//itemset contains variables of type <Data Type>
for(<Data Type> item : itemset) {
  //loop
}for (int i=0; i<arr.length; i++) 
{ 
    type var = arr[i];
    statements using var;
}
for (int i : array) { 
    System.out.println(i);
}

Source

Also in Java: