File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "collections.sort compiler error?" Watch "collections.sort compiler error?" New topic
Author

collections.sort compiler error?

maggie karve
Ranch Hand

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

Joined: Feb 19, 2008
Posts: 2902
    
    1

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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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
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.


SCJP 6.0 90%
Sagar Rohankar
Ranch Hand

Joined: Feb 19, 2008
Posts: 2902
    
    1

and if you really want your set to be sorted one, try using java.util.TreeSet ;)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: collections.sort compiler error?
 
Similar Threads
hashcodes
Regarding Hashcode
generics and collections: Q11, page 642 - is my understanding correct ?
What's wrong with this code? Why I am able to add duplicates with this code.
how will i get my values from collection?