Skip to content

Instantly share code, notes, and snippets.

@silveira
Created September 30, 2011 20:49
Show Gist options
  • Save silveira/1254938 to your computer and use it in GitHub Desktop.
Save silveira/1254938 to your computer and use it in GitHub Desktop.
PriorityQueue order
import java.util.*;
class Example {
public static void main(String[] args) {
Queue<String> q = new PriorityQueue<String>();
q.offer("carrot");
q.offer("apple");
q.offer("banana");
for(String fruit: q)
System.out.println(fruit);
/*
apple
carrot
banana
*/
System.out.println();
while(q.isEmpty()==false)
System.out.println(q.poll());
/*
apple
banana
carrot
*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment