1 import java.util.*;
2 public class test {
3
4 /**
5 * @param args
6 */
7 public static void main(String[] args) {
8 // TODO Auto-generated method stub
9 PriorityQueue<Integer> priQ=new PriorityQueue<Integer>(5,new Comparator<Integer>(){
10 public int compare(Integer o1,Integer o2){
11 return o2-o1;
12 }
13 });
14 priQ.add(4);
15 priQ.add(6);
16 priQ.add(1);
17 priQ.add(3);
18 priQ.add(9);
19 System.out.println(priQ.toString());
20 System.out.println("remove "+priQ.poll());
21 System.out.println(priQ.toString());
22 System.out.println("remove "+priQ.poll());
23 System.out.println(priQ.toString());
24 System.out.println("remove "+priQ.poll());
25 System.out.println(priQ.toString());
26 System.out.println("remove "+priQ.poll());
27 System.out.println(priQ.toString());
28 System.out.println("remove "+priQ.poll());
29 System.out.println(priQ.toString());
30 System.out.println("remove "+priQ.poll());
31 System.out.println(priQ.toString());
32 System.out.println("remove "+priQ.poll());
33 System.out.println(priQ.toString());
34 }
35 }
36