Import Java.util.Set;
Import Java.util.TreeSet;
public class Admin {
public static void Main (string[] args) {
String Fdbs = "WXB,WXA,FDA,WXB";
string[] str = fdbs.split (",");
Set set = new TreeSet ();
for (int i = 0; i < str.length; i++) {
Set.add (Str[i]);
}
str = (string[]) Set.toarray (new string[0]);
for (int i = 0; i < str.length; i++) {
System.out.println (Str[i]);
}
}
}
Annotations:
What is the difference between HashSet and TreeSet.
public class Treeset<e>
Extends abstractset<e>
Implements Sortedset<e>, Cloneable, java.io.Serializable
public class Hashset<e>
Extends abstractset<e>
Implements Set<e>, Cloneable, java.io.Serializable
One of the SortedSet is composed of: comparator<? Super E> Comparator ();
So the biggest difference between TreeSet and HashSet is the sort ...
New String[0] What does it mean.
Indicates that the elements inside are converted to string array types