This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PriorityQueue

 
sura watthana
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2993
12
Firefox Browser IntelliJ IDE Java Mac Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you greg.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic