I think that I have a rather simple question, but I can’t figure out how i am supposed to do it. I have created one multiple arraylist, where I want to store some data from an array.
I want to check which entries are the same.
For example, if array[0] = array[5] = array[8] but array[1] is not equal to any entry, and array[2] = array[3]
I would like to have for the arraylist look like
array2[0] | array2[5] | array2[8]
array2[2] | array2[3]
List<String> dup_non = new ArrayList<String>(), dn = new ArrayList <String>();
for (int m = 0; m < array.length ; m++)
{
for(int o = m + 1; o < array.length; o++)
{
if (array[m].equals(array[o] && m!=o)){
dup_non.add(array2[m])
dn.add(array2[m],array2[o])
}
else { ....
}
}
}
This code is what i was thinking more or less, since my array2 has unique elements, but it is not correct. It is correct, because array2 is not an array of integers.
If you have any idea, I would appreciate if you could share it.
Regards.
1 Answer