public class array{ public static void main(String args []){ int list1[] = {12, 32, 14, 35, 89, 16, 120}; int list2[] = {9, 12, 8, 17, 120, 35, 36}; Union(list1, list2); Intersection(list1, list2); } public static void Union(int list1[], int list2[]){ int unique[] = new int[15]; int counter = 1; System.out.println("FOR UNION : "); for(int i = 0; i < list1.length; i++){ unique[i] = list1[i]; counter++; } for(int j = 0; j < list2.length; j++){ unique[counter] = list2[j]; counter++; } int x = 0; while(x < (unique.length-1)){ int tmp = unique[x]; int z = x + 1; while(z < unique.length){ if(tmp == (unique[z])){ unique[z] = 0; break; } z++; } x++; } for(int y = 0; y < unique.length; y++){ System.out.print("\t" + unique[y] + "\t"); } \*int union[] = new int[20]; for(int y = 0; y < unique.length; y++){ if((unique[y]) == 0){ union[y] = unique[y+1]; }else{ union[y] = unique[y]; } System.out.print("\t" + union[y] + "\t"); }*/ } }

Ok in shorts if u run this...

It gives u 4 zeros at the wrong positions and I don't understand why...

if u unhide the last portion of the code it doesn't really replace the zeros with the following element...

AM TIRED AND WIRED AND HOPELESS SO THIS IS REALLY MY LAST RESORT :/