home *** CD-ROM | disk | FTP | other *** search
/ ActiveX Programming Unleashed CD / AXU.iso / jgl_1_1 / jgl_1_1.exe / examples / Stacks5.java < prev    next >
Encoding:
Java Source  |  1996-07-14  |  655 b   |  23 lines

  1. // Copyright(c) 1996 ObjectSpace, Inc.
  2. import jgl.*;
  3.  
  4. public class Stacks5
  5.   {
  6.   public static void main( String[] args )
  7.     {
  8.     // Use a GreaterString function object for comparing elements. This will 
  9.     // order strings in ascending order.
  10.     PriorityQueue queue = new PriorityQueue( new GreaterString() ); 
  11.     queue.push( "cat" );
  12.     queue.push( "dog" );
  13.     queue.push( "ape" );
  14.     queue.push( "bat" );
  15.     queue.push( "fox" );
  16.     queue.push( "emu" );
  17.  
  18.     System.out.println( "Pop and print each element." );
  19.     while( !queue.isEmpty() )
  20.       System.out.print( queue.pop() + " ");
  21.     System.out.println();
  22.     }
  23.   }