File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes PriorityQueue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "PriorityQueue" Watch "PriorityQueue" New topic
Author

PriorityQueue

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
Hi,

I'm wondering how PriorityQueue works with natural order of String. Does it use hashcode of String to determine the order?
anyone knows answer to this? please

thank you

sura

Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2853
    
  11

No, not the hashcode. That wouldn't give the natural order of String, which is simply alphabetical, or really lexicographical. It uses the String.compareTo(String) method. You can give the PriorityQueue a different Comparator to use if you want, say, a case-insensitive sorting.
sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
thank you greg.
 
Don't get me started about those stupid light bulbs.
 
subject: PriorityQueue