I'm having trouble extracting repeated numbers from a ArrayList
, here's the snippet of code:
for( int i = 0 ; i < houses.size(); i++ ) {
for( int j = 1; j < houses.size(); j++ ) {
if(houses.get(i).equals(houses.get(j)) && i!=j){
houses.remove(j);
}
}
}
It correctly deletes most of the repeated elements, but in some cases deletes a few more, I really wanted to know what's wrong with this code, as I can not figure it out.