The latest version of Java (version 1.5 and later) have for-each loop support. Groovy have many type of powerful loops as well as it support traditional Java loops. This is very simple example for for-each loop.
Java way for implementing for-each loop
public class ForEachLoopDemo { public static void main(String[] args) { String[] countryLists = {"India","US","UK"}; for(String country : countryLists) { System.out.println(country); } } }
Groovier way for implementing for-each loop
for(country in countryList) { println country }
Comments