I have an ArrayList of object containing a reference to their parent object.
I am trying to remove every objects within a specific parent (so equals to the parent object).
If I do:
System.out.println(parent);
my console output:
ParentObject@1f8166e5
if I do:
for(int i = 0; i < array.size(); i++){
if(array.get(i).getParent().equals(parent)){
array.remove(i);
}
}
And (test)
for(int i = 0; i < array.size(); i++){
if(array.get(i).getParent().equals(parent)){
System.out.println(parent + ":" + array.get(i).getParent());
}
}
My console output something like:
ParentObject@1f8166e5:ParentObject@1f8166e5
What's wrong with the snippet above?
Why array.remove(i) did not work?
remove()doesn't work?