import java.util.Iterator;
import java.util.TreeSet;
import java.util.Scanner;
import java.util.Set;
public class TreeSetContains {
// method to find the element in the given set
public static void is_Contains(Set<String> set) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter the element you want to search");
String str = sc.nextLine();
if (set.contains(str)) {
System.out.println("Element is present in the given Set");
} else {
System.out.println("Element is not present in the given set");
}
}
// method to find the complete set in another set
public static void is_Contains(Set<String> set1, Set<String> set2) {
if (set1.containsAll(set2)) {
System.out.println("set2 is present in set1");
} else {
System.out.println("set2 is not present in set1");
}
}
public static void main(String[] args) {
// creating our TreeSet
Set<String> ts = new TreeSet<>();
// adding element to our set
// insertion order is maintained here
ts.add("Neha");
ts.add("Nisha");
ts.add("Nishu");
ts.add("Rekha");
ts.add("Madhu");
ts.add("Disha");
ts.add("Tara");
ts.add("Tara"); // duplicate element can't be added
// creating another TreeSet
Set<String> ts1 = new TreeSet<>();
ts1.add("Reena");
ts1.add("Sweety");
ts1.add("Sheetal");
// creating another TreeSet
Set<String> ts2 = new TreeSet<>();
ts2.add("Nisha");
ts2.add("Nishu");
ts2.add("Rekha");
ts2.add("Madhu");
ts2.add("Disha");
// is_Contains(ts);
is_Contains(ts, ts1);
is_Contains(ts, ts2);
}
}