集册 Java实例教程 创建树集并为其添加值

创建树集并为其添加值

欢马劈雪     最近更新时间:2020-01-02 10:19:05

351
提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
创建树集并为其添加值


import java.util.TreeSet;;//n  o  w  j  a  v  a . c o m 提供

 

public class Main {

 

  public static void main(String[] args) {

    TreeSet tSet = new TreeSet();

   

    tSet.add(new Integer("1"));

    tSet.add(new Integer("2"));

    tSet.add(new Integer("3"));

   

    System.out.println("TreeSet contains.." + tSet);  

  }

}