class HashSetDemo
{
public static void main(String[] args)
{
//Creating hashset for Even Numbers
HashSet<Integer> evenNumbers = new HashSet<>();
// Using add() method
evenNumbers.add(2);
evenNumbers.add(4);
evenNumbers.add(6);
System.out.println("Even Number HashSet: " + evenNumbers);
//Creating hashset for Numbers
HashSet<Integer> numbers = new HashSet<>();
// Using addAll() method
numbers.addAll(evenNumbers);
numbers.add(5);
numbers.add(7);
numbers.add(3);
System.out.println("All Numbers HashSet: " + numbers);
//Creating hashset for Prime Numbers
HashSet<Integer> primeNumbers = new HashSet<>();
primeNumbers.add(3);
primeNumbers.add(5);
primeNumbers.add(7);
System.out.println("Prime Number HashSet :" + primeNumbers);
// Check if primeNumbers is a subset of numbers
boolean result = numbers.containsAll(primeNumbers);
System.out.println("Is prime numbers is subset of numbers? " + result);
boolean value2 = numbers.removeAll(evenNumbers);
System.out.println("Are all elements removed? " + value2);
}
}