Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

collections.sort compiler error?

 
maggie karve
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First, I searched for the problem, I didn't find. Then I looked at code and somewhere in the code, you comment your question, which is at all not attentive in any manner.
Second, if you posted the error that will yield more answer and error are sometime self explainable.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What type of objects does Collections.sort accepts ? Check the API.
 
Anuradha Prasanna
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

java.util.Collections contains the following methods for sorting,

1)static void sort(List)
2)static void sort(List, Comparator)


from the above, we can see, the sort() method takes only argument of type List to sort. It does not sort HashSets.
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and if you really want your set to be sorted one, try using java.util.TreeSet ;)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic