1  import java.util.PriorityQueue;
  2  
  3  /**
  4     This program demonstrates a priority queue of work orders. The
  5     most important work orders are removed first.
  6  */
  7  public class PriorityQueueDemo
  8  {
  9     public static void main(String[] args)
 10     {
 11        PriorityQueue<WorkOrder> q = new PriorityQueue<WorkOrder>();
 12        q.add(new WorkOrder(3, "Shampoo carpets"));
 13        q.add(new WorkOrder(7, "Empty trash"));
 14        q.add(new WorkOrder(8, "Water plants"));
 15        q.add(new WorkOrder(10, "Remove pencil sharpener shavings"));
 16        q.add(new WorkOrder(6, "Replace light bulb"));
 17        q.add(new WorkOrder(1, "Fix broken sink"));
 18        q.add(new WorkOrder(9, "Clean coffee maker"));
 19        q.add(new WorkOrder(2, "Order cleaning supplies"));
 20  
 21        while (q.size() > 0)
 22        {
 23           System.out.println(q.remove());    
 24        }
 25     }
 26  }