import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Scanner;
import java.util.Set;
public class LinkedHashSetContains {
// 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 LinkedHashSet
Set<String> lhs = new LinkedHashSet<>();
// adding element to our set
// insertion order is maintained here
lhs.add("Neha");
lhs.add("Nisha");
lhs.add("Nishu");
lhs.add("Rekha");
lhs.add("Madhu");
lhs.add("Disha");
lhs.add("Tara");
lhs.add("Tara"); // duplicate element can't be added
// creating another LinkedHashSet
Set<String> lhs1 = new LinkedHashSet<>();
lhs1.add("Reena");
lhs1.add("Sweety");
lhs1.add("Sheetal");
// creating another LinkedHashSet
Set<String> lhs2 = new LinkedHashSet<>();
lhs2.add("Nisha");
lhs2.add("Nishu");
lhs2.add("Rekha");
lhs2.add("Madhu");
lhs2.add("Disha");
// is_Contains(lhs);
is_Contains(lhs, lhs1);
is_Contains(lhs, lhs2);
}
}