It can iterate over a Collection without the need to call the iterator method. The syntax is
for (Type identifier : expression) { statement (s) }
In which expression must be an Iterable.
import java.util.Arrays; import java.util.List; public class MainClass { public static void main(String[] args) { List list = Arrays.asList("A", "B", "C", "D"); for (Object object : list) { System.out.println(object); } } }
A B C D