The
iterator() method of
BlockingDeque returns an iterator over the elements in this deque in a proper sequence. The elements will be returned in order from first (head) to last (tail). The returned iterator is a "weakly consistent" iterator.
Syntax:
public Iterator iterator()
Parameters: This method does not accept any parameter.
Returns: This method returns an iterator over the elements in this deque in a proper sequence.
Note: The iterator() method of
BlockingDeque has been inherited from the
LinkedBlockingDeque class in Java.
Below programs illustrate iterator() method of
BlockingDeque:
Program 1:
Output:
The iterator values of BlockingDeque are:
74381793
5278367
35658786
7855642
Program 2: