java.util.TreeSet.clone() 方法示例 java.util.TreeSet.clear() 方法示例 java.util.TreeSet.comparator() 方法示例 java.util.TreeSet.clone() 方法示例 package com.codingdict; import java.util.Iterator; import java.util.TreeSet; public class TreeSetDemo { public static void main(String[] args) { // creating TreeSet TreeSet <Integer>tree = new TreeSet<Integer>(); TreeSet <Integer>clonetree = new TreeSet<Integer>(); // adding in the tree tree.add(12); tree.add(13); tree.add(14); // cloning tree into clinetree clonetree = (TreeSet)tree.clone(); // creating iterator Iterator iterator; iterator = clonetree.iterator(); // displaying the clonetree data System.out.println("Tree set data: "); while (iterator.hasNext()) { System.out.println(iterator.next() + " "); } } } java.util.TreeSet.clear() 方法示例 java.util.TreeSet.comparator() 方法示例