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


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

public PriorityQueue(Collection <? extends E> c)


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

import java.util.ArrayList;
import java.util.Collection;
import java.util.PriorityQueue;
/*from  w  ww .  ja v a2 s.  co  m*/
public class Main {
  public static void main(String args[]) {

    Collection<String> c = new ArrayList<String>();

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


The code above generates the following result.