public static void main(String[] args) {
int a[] = {3, 10, 4, 2, 8};
int[] b = {10, 4, 12, 3, 23, 1, 8};
int[] c = new int[(int)Math.min(a.length, b.length)];
int i=0;
for(int f=0;f
Hope it helps. Or if you have time complexity issue then try Java Set.