## Enhanced For Loop In Java, can use an enhanced for loop to access each element of an iterable object via ```java List<String> myList = Arrays.from(0, 1, 2, 3, 4); for (String s : myList) { System.out.println(s); } ``` It's only used for read operations. Index is not provided. ## For Each Loop `forEach()` is a built-in method for Collections that iterates over the elements in a collection in a more concise manner. ```java List<String> myList = Arrays.from(0, 1, 2, 3, 4); myList.forEach(element -> System.out.println(element)); // for maps Map<String, int> histogram = new HashMap<String, int>(); histogram.put("foo", 1); histogram.put("bar", 2); histogram.put("baz", 3); histogram.forEach((key, value) -> System.out.println(key + ": " + value)); // using Map.entrySet() histogram.entrySet().forEach(entry -> LOG(entry.getKey() + ": " + entry.getValue())); ``` The `forEach()` has some limitations though - No modifying elements - No using counters - No accessing elements before or after (cannot do array[i + 1]) ## References - [ForEach - Baeldung](https://www.baeldung.com/foreach-java)