Java ArrayBlockingQueue iterator() Method

The iterator() method of ArrayBlockingQueue class returns an iterator across the elements of this queue in a sequential manner.

The elements returned will follow order from first (head) to last (tail).

Syntax:

Parameters:

NA

Specified By:

The iterator() method of ArrayBlockingQueue class is specified by:

  1. iterator() method in interface Collection<E>.
  2. iterator() method in interface Iterable<E>.
  3. iterator() method in class AbstractCollection<E>.

Return Value:

The iterator() method returns an iterator across the elements of this queue in a sequential manner.

Example 1

Output:

Reema
Rahul
Rita
Ramesh

Example 2

Output:

Reema       Panda     [email protected]
Geetanjali  Sharma    [email protected]
Vineet      Tanjea    [email protected]
Himanshu    Bhardwaj  [email protected]

Example 3

Output:

71018
8000
1178
1190
Max number = 71018
Min number = 1178