need a new array which will be having elements based on if 'array i' will be compared to 'array j'
10 will be compared against 'array j'and and so on ,Only unmatched elements index will be the elements of new array
for 10,20,3,4 will be unmatched so their indexes will be printing into another array
First, have you learned how to use loops yet? You will need to get somewhat comfortable with them, as you probably need to nest them for the solution. Second, have you learned the collections library yet? It will probably be easier to use a Java collection, and then convert it to an array, as you probably won't know how elements in the result to start.
Note: when you get an error, post the complete error message.
About your code: you are using two loops so that you can find the size of the array, but Lists will grow to any size. Try using an ArrayList and one loop, then converting the List into an array if need be.
All things are lawful, but not all things are profitable.
In Java® always put the  as part of the type. It should read int array not int array. The fact that you can get such code past the compiler does not make it good code
I find it understand how you get from two 5‑element arrays to one 4‑element array. Why is the 2 matched? Does it mean there is a 2 in the other array at any location? I presume this is an exercise in using nested loops. If so, please use variable names which people can understand. Things like nii are very difficult to understand.
The output array is the set of indices that contain numbers unique to the i array. Thus the 2 is there because the "3" at index 2 is unique. Same for 0 (the "10" at index 0 is unique), 1 (the "20" at index 1 is unique), and 4 (the "4" at index 4 is unique).
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop