Hi all, I came accross this piece of code on "Sahir's TestCafe MockTest".
I was very sure that equal methods would return false(because Vectors and ArrayList are two different classes and their instances cannot be equal). But It returned true. Can someone expalin the reason for this behaviour. Thanks in advance.
Originally posted by Varalakshmi Ramanarayan: ... Before posting, I just looked at Vector and ArrayList in the API...
Glad you got it!
In this example, you're calling equals on an ArrayList reference (a.equals(v)), so you would check the API for ArrayList.
In the documentation for ArrayList, you won't see the equals method listed in the "Method Summary" section, but directly underneath that, you will see the equals method listed in the "Methods inherited from class java.util.AbstractList" section. Clicking on that link gives you the description.