java treeset contains not working code example
Example: 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);
System.out.println("Does TreeSet contains 'apple'? " + ts.contains("apple"));
System.out.println("Does TreeSet contains 'grapes'? " + ts.contains("grapes"));
System.out.println("Does TreeSet contains 'red'? " + ts.contains("red"));
}
}