I want to compare two lists. Since we code to interface using List, which does not inherit the equals from from the Object class. How do I do this?
I want to compare two lists. Since we code to interface using List ,
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Even though the
Listinterface does not contain anequalsmethod, the list-classes may (and does) still implement theequalsmethod.From the API docs on
AbstractList(inherited by for instanceArrayList,LinkedList,Vector):The same applies to for instance the
toString,hashCodemethod and so on.As @Pascal mentions in the comments, the List interface mentions the
equalsmethod and states the following in the documentation: