friends, I am new to Java-Collection. I want to ask does Collections.sort()
method only used for/by collections which are List
type. I was unable t
My first step with these questions is to look at Java's documentation, which will help you a lot in understanding and debugging things.
http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html
If you look at the sort method, there, it is expecting a List.
sort(List list)
It has another overriden version, but this also needs a list, as well as a comparator.
sort(List list, Comparator super T> c)
This is why you are getting an error. There is not a method defined for sort (HashSet)