Answers for "TreeSet contains(Object o) method in java"

1

TreeSet contains(Object o) method in java

import java.util.TreeSet;
public class TreeSetContainsObjectMethodExample
{
   public static void main(String[] args)
   {
      TreeSet<String> ts = new TreeSet<String>();
      ts.add("mango");
      ts.add("grapes");
      ts.add("apple");
      ts.add("banana");
      ts.add("orange");
      ts.add("pineapple");
      System.out.println("TreeSet: " + ts);
      // check for "apple"
      System.out.println("Does TreeSet contains 'apple'? " + ts.contains("apple"));
      // check for "grapes"
      System.out.println("Does TreeSet contains 'grapes'? " + ts.contains("grapes"));
      // check for "red"
      System.out.println("Does TreeSet contains 'red'? " + ts.contains("red"));
   }
}
Posted by: Guest on October-27-2020

Code answers related to "TreeSet contains(Object o) method in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language