⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 subtree.java

📁 Java学习源代码检索系统免费版
💻 JAVA
字号:
//==============================================================
// SubTree.java - Demonstrate the SortedSet.subSet() method
//
// Java学习源代码检索系统 Ver 1.0 20031015 免费正式版
// 版权所有: 中国IT认证实验室(www.ChinaITLab.com)
// 程序制作: ChinaITLab网校教研中心
// 主页地址: www.ChinaITLab.com    中国IT认证实验室
// 论坛地址: bbs.chinaitlab.com  
// 电子邮件: Java@ChinaITLab.com
//==============================================================

import java.util.*;
import java.io.*;

class SubTree {
// Display contents of a SortedSet container
 static void showSet(SortedSet S, String msg) {
  System.out.println("\n" + msg);
  Iterator I = S.iterator();
  while (I.hasNext())
   System.out.print("  " + I.next());
 }

 public static void main(String args[]) {
// Create the TreeSet container and add some objects to it
  TreeSet myTree = new TreeSet();
  myTree.add("Peach");
  myTree.add("Banana");
  myTree.add("Cherry");
  myTree.add("Apple");
  myTree.add("Pear");
  myTree.add("Kiwi");
  myTree.add("Grapefruit");

// Get a non-inclusive subset of the tree
  TreeSet subTree = 
   (TreeSet)myTree.subSet("Cherry", "Peach");
// Get an inclusive subset of the tree
//  TreeSet subTree = 
//   (TreeSet)myTree.subSet("Cherry", "Peach\0");

// Display both trees  
  showSet(myTree, "Full TreeSet container:");
  showSet(subTree, "Subset of container:");
 }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -