import java.util.*;
public class Ex_PriorityQueue_1{
public static void main(String args[]){
Comparator<String> c = new Comparator<String>(){
public int compare(String a , String b){
return a.compareTo(b)*-1;
}
};
PriorityQueue<String> pq = new PriorityQueue<String> (3,c);
pq.offer("c");
pq.offer("a");
pq.offer("b");
String s;
while((s = pq.poll())!= null){
System.out.println(s+" ");
}
}
}
PriorityQueue
關於Comparator別人哦論點
http://give.pixnet.net/blog/post/11346747-how-to-sort-objects-in-java-%28%E6%8E%92%E5%BA%8Fjava%E7%89%A9%E4%BB%B6%29
沒有留言:
張貼留言