Create a new set that contains all the elements that are in
* Create a new set that contains all the elements that are in both this set and the other set.
 * @param set2
 * the second set in the intersection
 * @precondition
 * set2 is not null
 * @postcondition
 * the returned set is smaller than either this set or set2
 * @return
 * the intersection of this set and set2
 
 public IntSet intersection(IntSet set2)
 {
 // If set2 is null, then a NullPointerException is thrown.
 }
Solution
import java.util.*;
 public class setex {
    public static void main(String[] args) {
        Set<Integer>set3=new HashSet<Integer>();
        Set<Integer>set4=new HashSet<Integer>();
        set3.add(1);
        set3.add(2);
        set4=intersection(set3);
        System.out.println(set4);
    }
      
 public static HashSet<Integer> intersection(Set<Integer> set3){
 Set<Integer>hset=new HashSet<Integer>(set3);
 System.out.println(hset.size());
try{
 if(hset.size()==0){}
       
 }catch(Exception e){
 System.out.println(e);
 }
 Set<Integer>set2=new HashSet<Integer>(hset);
 set2.add(3);
 set2.add(4);
 return (HashSet<Integer>) set2;
 }
 }

