aspose 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
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: 2851
    
  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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PriorityQueue