Iterating through Collections
Earlier in this chapter, when working with Exercise 01, Creating the AnalyzeInput Application we stopped when we were about to make searches through the data. We made it to the point where we had to iterate through the data and look for characteristics such as word frequency.
Iterators are used in Java to browse through collections. Let's look at a simple example that involves extracting the elements from a simple list one by one and printing them out.
import java.util.*; public class Example16 { public static void main(String[] args) { List<Integer> array = new ArrayList<>(); array.add(5); array.add(2); array.add(37); Iterator<Integer> iterator = array.iterator(...