public int indexOf(Object o) {
if (o == null) {
for (int i = 0; i < size; i++)
if (elementData[i]==null)
return i;
} else {
for (int i = 0; i < size; i++)
if (o.equals(elementData[i]))
return i;
}
return -1;
}
This is actual method in Arraylist ,after reading i came to know that i must override the equal method in the class A since i am passing instance of A as a parameter .
finally it worked for me.
If yoy see above code
if (o.equals(elementData[i]))
they are checking parameter class’s equal method.
solved IndexOf not working on childList [closed]