A sorted set is a set that maintains its items in a sorted order : SortedSet « Collections « Java Tutorial






import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
  public static void main(String[] argv) throws Exception {
    SortedSet<String> set = new TreeSet<String>();
    set.add("b");
    set.add("c");
    set.add("a");

    Iterator it = set.iterator();
    while (it.hasNext()) {
      Object element = it.next();
    }
    String[] array = (String[]) set.toArray(new String[set.size()]);
  }
}








9.24.SortedSet
9.24.1.A sorted set is a set that maintains its items in a sorted order