Iterators

External to Internal Iterators. Given

List<Integer> numbers = Arrays.asList(1,2,3,4,5,6,7,8,9,10)

External Iterators

for (int i = 0; i < numbers.size();  i++){
	 System.out.println(numbers.get(i));
}

Internal Iterators

numbers.forEach((Integer E) -> System.out.println(e));

or even type inference in Java

numbers.forEach((e) -> System.out.println(e));

or method reference

numbers.forEach(System.out::println);
Edit this page on GitHub

Links to this note