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
The error is because the Collections class only supports a List.
public static > void sort(List list)
To sort your collection, you can try something like:
Collection collection=new HashSet();
collection.add("zebra");
collection.add("frog");
collection.add("bison");
collection.add("puma");
ArrayList temp = new ArrayList(collection);
Collections.sort(temp);
collection = new HashSet(temp);
Hope this helps.