home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 1998 October
/
PCWorld_1998-10_cd.bin
/
software
/
prehled
/
inprise
/
JSAMPLES.Z
/
Stacks5.java
< prev
next >
Wrap
Text File
|
1998-05-08
|
719b
|
25 lines
// Copyright(c) 1996,1997 ObjectSpace, Inc.
import com.objectspace.jgl.*;
import com.objectspace.jgl.predicates.*;
public class Stacks5
{
public static void main( String[] args )
{
// Use a GreaterString function object for comparing elements. This will
// order strings in ascending order.
PriorityQueue queue = new PriorityQueue( new GreaterString() );
queue.push( "cat" );
queue.push( "dog" );
queue.push( "ape" );
queue.push( "bat" );
queue.push( "fox" );
queue.push( "emu" );
System.out.println( "Pop and print each element." );
while ( !queue.isEmpty() )
System.out.print( queue.pop() + " ");
System.out.println();
}
}