```
class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
Set<Integer> s1 = new HashSet<Integer>(Arrays.asList(IntStream.of(nums1).boxed().toArray(Integer[]::new)));
s1.retainAll (new HashSet<Integer>(Arrays.asList(IntStream.of(nums2).boxed().toArray(Integer[]::new))));
return Stream.of(s1.toArray(new Integer[s1.size()])).mapToInt(Number::intValue).toArray();
}
}
```