java.util.TreeSet.clear() 方法示例 java.util.TreeSet.ceiling(E e) 方法示例 java.util.TreeSet.clone() 方法示例 java.util.TreeSet.clear() 方法示例 package com.codingdict; import java.util.Iterator; import java.util.TreeSet; public class TreeSetDemo { public static void main(String[] args) { // creating a TreeSet TreeSet <Integer>treeadd = new TreeSet<Integer>(); // adding in the tree set treeadd.add(12); treeadd.add(13); treeadd.add(14); treeadd.add(15); // create an iterator Iterator iterator; iterator = treeadd.iterator(); // displaying the Tree set data System.out.println("Tree set data: "); while (iterator.hasNext()) { System.out.println(iterator.next() + " "); } // clearing the set System.out.println("Clearing tree"); treeadd.clear(); System.out.println("Size of the tree: "+treeadd.size()); } } java.util.TreeSet.ceiling(E e) 方法示例 java.util.TreeSet.clone() 方法示例