Effective Java with Groovy - Favour Internal Iterators
Let's start with the following code making use of the traditional for loop. List<String> languages = List.of("Java", "Groovy", "Kotlin"); // List.of() requires Java 9 or above for (int i = 0; i < languages.size(); i++) { System.out.println(languages.get(i)); } Compare the above code to…