Saturday, 31 August 2013

How can I remove duplicates out of an ArrayList?

How can I remove duplicates out of an ArrayList?

for (int i = 0; i < arrayP.size(); i++) {
if (arrayP.get(i) == What to put here?) {
arrayP.remove(i)
}
}
If I put i+1 it just compares side by side. How can I get it to run
through each element?
Element 1 then run through the whole ArrayList. Then element 2 run through
ArrayList.

No comments:

Post a Comment