class Solution {public static int[] intersection(int[] nums1, int[] nums2) {
int length;
List<Integer> list=new ArrayList<>();
if(nums1.length>nums2.length){length=nums2.length;}else {length=nums1.length;}
int[] result=new int[length];
int sum=0;
for (int i : nums1) {for (int i1 : nums2) {if(i==i1){if(!list.contains(i)){result[sum]=i;
sum++;
list.add(i);
}
}
}
}
return Arrays.copyOf(result,sum);
}
public static void main(String[] args) {int[] nums1={1,2,3,4,4,6};
int[] nums2={2,3,4,5,6,7};
for (int i : intersection(nums1, nums2)) {System.out.println(i);
}
}
}