public static < T > Set < T > intersection ( Set < T > setA , Set < T > setB ) { Set < T > intersection = new HashSet < T > ( setA ) ; intersection . retainAll ( setB ) ; return intersection ; }
This method finds the intersection between set A and set B