I want to compare two different types of array list i.e.
ArrayList<A> list1 = new ArrayList<A>();
ArrayList<B> list2 = new ArrayList<B>();
So I want to compare list1 and list2 and get the count of indexes at which both are same?
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.
(I have no idea what types you have for
AandB, but I’ll just assume that it makes sense to compare them usingequals.)You can use
Iterators to iterate over the lists, and use an if-statement to increment a counter for each element that equal.