java.util.TreeSet.tailSet(E fromElement) 方法示例 java.util.TreeSet.subSet(E fromElement,E toElement) 方法示例 java.util.TreeSet.tailSet(E fromElement,boolean inclusive) 方法示例 java.util.TreeSet.tailSet(E fromElement) 方法示例 package com.codingdict; import java.util.TreeSet; import java.util.Iterator; public class TreeSetDemo { public static void main(String[] args) { // creating a TreeSet TreeSet <Integer>treeadd = new TreeSet<Integer>(); TreeSet <Integer>treetailset = new TreeSet<Integer>(); // adding in the tree set treeadd.add(1); treeadd.add(2); treeadd.add(3); treeadd.add(4); treeadd.add(5); treeadd.add(6); treeadd.add(7); treeadd.add(8); // creating tail set treetailset = (TreeSet)treeadd.tailSet(4); // create iterator Iterator iterator; iterator = treetailset.iterator(); // displaying the Tree set data System.out.println("Tree tail set data: "); while (iterator.hasNext()) { System.out.println(iterator.next() + " "); } } } java.util.TreeSet.subSet(E fromElement,E toElement) 方法示例 java.util.TreeSet.tailSet(E fromElement,boolean inclusive) 方法示例