Try this (untested!) code:
public static <T> boolean areEqual(Set<T> set, T[] array) {
return set.equals(new HashSet<T>(Arrays.asList(array)));
}
Edit: Sorry, I only read the compare part, not the intersection part.
import java.util.*;
public class IntersectionExample {
public static void main(String[] args) {
String[] a = {"a","b","b","c","d","e","f"};
String[] b = {"b","d","f","h","j","k"};
Set < String > sb = new HashSet < String > (Arrays.asList(b));
String[] result = intersection(a, sb);
System.out.println(Arrays.toString(result));
}
public static String[] intersection(String[] a, Set < String > sb) {
Set < String > sa = new HashSet < String > (Arrays.asList(a));
sa.retainAll(sb);
return sa.toArray(new String[0]);
}
}