java.util.TreeSet.pollLast() 方法示例 java.util.TreeSet.pollFirst() 方法示例 java.util.TreeSet.remove(Object o) 方法示例 java.util.TreeSet.pollLast() 方法示例 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(1); treeadd.add(13); treeadd.add(17); treeadd.add(2); // retrieve and remove the last element System.out.println("Last element is: "+treeadd.pollLast()); // create iterator Iterator iterator; iterator = treeadd.iterator(); // displaying the Tree set data System.out.println("Tree set data after removing: "); while (iterator.hasNext()) { System.out.println(iterator.next() + " "); } } } java.util.TreeSet.pollFirst() 方法示例 java.util.TreeSet.remove(Object o) 方法示例