java.util.PriorityQueue.size() 方法示例


java.util.PriorityQueue.size() 方法示例

package com.codingdict;

import java.util.*;

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

      // create priority queue
      PriorityQueue < Integer >  prq = new PriorityQueue < Integer > ();

      // insert values in the queue
      for ( int i = 3; i  <  10; i++ ) {  
         prq.add (new Integer (i)) ;
      }

      System.out.println("Size of the queue is: "+ prq.size());
      System.out.println("Priority queue values are: "+ prq);
   }
}