my dog learned polymorphism
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes collections.sort compiler error? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "collections.sort compiler error?" Watch "collections.sort compiler error?" New topic

collections.sort compiler error?

maggie karve
Ranch Hand

Joined: Dec 29, 2009
Posts: 187
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904

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.

[LEARNING bLOG] | [Freelance Web Designer] | [and "Rohan" is part of my surname]
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

What type of objects does Collections.sort accepts ? Check the API.

[My Blog]
All roads lead to JavaRanch
Anuradha Prasanna
Ranch Hand

Joined: Mar 09, 2006
Posts: 115

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.

SCJP 6.0 90%
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2904

and if you really want your set to be sorted one, try using java.util.TreeSet ;)
I agree. Here's the link:
subject: collections.sort compiler error?
It's not a secret anymore!