利用TreeSet实现,
public class TestArray {
public static void main(String[] args) {
String[] a = { "a", "cb", "c", "a", "ab" };
TreeSet<String> vinFlag = new TreeSet<String>();
for (String s : a) {
vinFlag.add(s);
}
for (String s : vinFlag) {
System.out.print(" " + s);
}
}
}
执行效果如下: