Javatpoint Logo
Javatpoint Logo

Java PriorityQueue iterator() Method

The iterator() method of the PriorityQueue class returns an iterator over the elements in this queue.

The elements are not returned in any particular order by the iterator.

Syntax

Parameter

NA

Specified By

The iterator() method of the PrioriryQueue 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 over the elements in this queue.

Example 1

Test it Now

Output:

Brian
Elena
Dominic
Letty

Example 2

Test it Now

Output:

Ascending order :
200 780 654 1090

Example 3

Test it Now

Output:

1 Amit
2 Simran
3 Raj
4 Barun
Next TopicJava PriorityQueue



Help Others, Please Share

facebook twitter pinterest