import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;
import javax.management.monitor.StringMonitor;
public class LinkedHashSetRemoveAll {
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("Neha");
lhs1.add("Nisha");
lhs1.add("Madhu");
System.out.println("Before invoking removeAll() method,lhs and lhs1");
System.out.println(lhs);
System.out.println(lhs1);
lhs.removeAll(lhs1);
System.out.println("After invoking removeAll() method,lhs");
System.out.println(lhs);
// deleting all elements
lhs.clear();
lhs1.clear();
System.out.println("After invoking clear() method,lhs and lhs1 :");
System.out.println(lhs);
System.out.println(lhs1);
}
}