1int [] intArray = { 10, 20, 30, 40, 50 };
2
3for( int value : intArray ) {
4 System.out.println( value );
5}
1List<String> someList = new ArrayList<String>();
2// add "monkey", "donkey", "skeleton key" to someList
3for (String item : someList) {
4 System.out.println(item);
5}
1public class ForEachLoopExample
2{
3 public static void main(String[] args)
4 {
5 int[] numbers = {2, 4, 6, 8, 10};
6 // for each loop
7 for(int n : numbers)
8 {
9 System.out.println(n);
10 }
11 }
12}