Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getting object from arraylist using equals method - java

I have a two list of objects. I want to compare both the lists. I have custom objects in these two lists. I thought i can override the equals method and get the object from the array list like - list.get(objectRef) and this should give the required object based on equals method comparison. But just came to know there is no such support yet.

Instead of looping through the entrie list and finding it, is there anyway that will give my required object from list by a single call. is it available in any apache utils lib or any external lib?

Thanks in advance

like image 527
Mohamed Iqzas Avatar asked Dec 07 '22 05:12

Mohamed Iqzas


1 Answers

You can use:

list.get(list.indexOf(objectRef));
like image 112
Azodious Avatar answered Dec 22 '22 01:12

Azodious