The
iterator() method of
CopyOnWriteArrayList returns an iterator over the elements in this list in proper sequence. The iterator does NOT support the remove method.
Syntax:
public Iterator iterator()
Parameters: The function does not accept any parameters.
Return Value: The function returns an iterator over the elements in the list.
Below programs illustrate the above function:
Program 1:
Output:
CopyOnWriteArrayList: [32, 67, 67, 100]
The iterator values of CopyOnWriteArrayList are:
32
67
67
100
Program 2: