TreeSet实现了SortedSet接口
package iotest;
import java.util.SortedSet;
import java.util.TreeSet;
public class sset {
public static void main(String args[]){
SortedSet<String> alls=new TreeSet<String>();
alls.add("A");
alls.add("M");
alls.add("D");
alls.add("F");
alls.add("F");
System.out.println(alls);
System.out.println(alls.first());
System.out.println(alls.last());
System.out.println(alls.headSet("F"));
System.out.println(alls.tailSet("D"));
System.out.println(alls.subSet("D", "F"));
}
}