treeset contains 28object o 29 method in java

Solutions on MaxInterview for treeset contains 28object o 29 method in java by the best coders in the world

showing results for - "treeset contains 28object o 29 method in java"
Olivia
04 Jan 2020
1import java.util.TreeSet;
2public class TreeSetContainsObjectMethodExample
3{
4   public static void main(String[] args)
5   {
6      TreeSet<String> ts = new TreeSet<String>();
7      ts.add("mango");
8      ts.add("grapes");
9      ts.add("apple");
10      ts.add("banana");
11      ts.add("orange");
12      ts.add("pineapple");
13      System.out.println("TreeSet: " + ts);
14      // check for "apple"
15      System.out.println("Does TreeSet contains 'apple'? " + ts.contains("apple"));
16      // check for "grapes"
17      System.out.println("Does TreeSet contains 'grapes'? " + ts.contains("grapes"));
18      // check for "red"
19      System.out.println("Does TreeSet contains 'red'? " + ts.contains("red"));
20   }
21}