java.util.TreeSet.contains() 方法示例


java.util.TreeSet.contains() 方法示例

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);

      // check existence of 15  
      System.out.println("Checking existence of 15 ");
      System.out.println("Is 15 there in the set: "+treeadd.contains(15));
   }    
}