Getting object from arraylist using equals method - java

I have two lists of objects. I want to compare both lists. I have custom objects in these two lists. I thought I could override the equals method and get an object from a list of arrays of the type - list.get (objectRef), and this should give the desired object based on a comparison of the equals method. But I just found out that there is no such support yet.

Instead of iterating over the entrie list and finding it, in any case, this will give my required object from the list with one call. Is it available in any apache utils lib or any external lib?

Thanks in advance

+4
source share
1 answer

You can use:

list.get(list.indexOf(objectRef)); 
+12
source

Source: https://habr.com/ru/post/1500505/


All Articles