Java Collection Tutorial - Java PriorityQueue(SortedSet <? extends E > c) Constructor


PriorityQueue(SortedSet <? extends E > c) constructor from PriorityQueue has the following syntax.

public PriorityQueue(SortedSet <? extends E> c)


In the following code shows how to use PriorityQueue.PriorityQueue(SortedSet <? extends E > c) constructor.

import java.util.PriorityQueue;
import java.util.SortedSet;
import java.util.TreeSet;
/*from   w ww.  jav  a  2  s .  co m*/
public class Main {
  public static void main(String args[]) {

    SortedSet<String> set = new TreeSet<String>();

    PriorityQueue<String> p = new PriorityQueue<String>(set);


The code above generates the following result.