Java PriorityQueue(int initialCapacity) Constructor

Syntax

PriorityQueue(int initialCapacity) constructor from PriorityQueue has the following syntax.

public PriorityQueue(int initialCapacity)

Example

In the following code shows how to use PriorityQueue.PriorityQueue(int initialCapacity) constructor.


/*w w w.j  a  va  2s .co  m*/
import java.util.PriorityQueue;

public class Main {
   public static void main(String args[]) {

      PriorityQueue<Integer>   prq = new PriorityQueue<Integer>(100) ; 
       
      for ( int i = 0; i < 10; i++ ){  
         prq.add (i) ; 
      }      
      System.out.println(prq) ; 
   }
}

The code above generates the following result.