Assuming I have class like this:
class A {
int elementA;
int elementB
}
I also have an ArrayList
like this: ArrayList<A> listObj
.
How can I check if that list contains an object using only some of the properties of A
? E.g. considering only elementA
for finding if object newA{elementA}
is already in the list?
For object A
I have defined an equals
method, where I consider only the elementA
, however this is not enough.