import java.util.*;
public class TreeSetDemo {
public static void main(String[] argv) {
TreeSet tm = new TreeSet(String.CASE_INSENSITIVE_ORDER);
tm.add("Gosling");
tm.add("da Vinci");
tm.add("van Gogh");
tm.add("Java To Go");
tm.add("Vanguard");
tm.add("Darwin");
tm.add("Darwin"); // TreeSet is Set, 忽略重复内容.
System.out.println("Lowest is " + tm.first());
System.out.println(tm.tailSet("k").toArray().length + " elements higher than /"k/"");
System.out.println("列表排序:");
java.util.Iterator t = tm.iterator();
while (t.hasNext())
System.out.println(t.next());
}
}
TreeSetDemo
最新推荐文章于 2025-08-31 12:09:08 发布
