public static int[] intersection(int[] nums1, int[] nums2) {

return IntStream.of(nums2).distinct().filter(IntStream.of(nums1).boxed().collect(Collectors.toSet())::contains).toArray();

}

Ofc i can do it faster as all xD but it's not funny cuz problem is soooo easy ;)