Question: what is the difference between foreach and iterator in java?
Answer: Iterator vs forEach in Java. Collections can be iterated easily using two approaches. Using for-Each loop − Use a foreach loop and access the array using object. Using Iterator − Use a foreach loop and access the array using object.