To sequentially access elements of an array list, we use the iterator() method. We must import java.util.Iterator package to use this method. For example,
Output looks like ArrayList: Dog, Cat, Horse, Zebra,. hasNext() returns true if there is a next element in the array list. next() returns the next element in the array list.