I am doing an electronic messaging exercise with different classes and applying inheritance.
I would like to know how to solve the following method: isMember(...)
: a contact identifier is passed as a parameter (I already have it done in the main class with a method called getId) and it returns true if it is contained in the group (directly or indirectly), and false, if not found.
My main problem is not knowing how to compare each id with those that make up a group (class on which I am working).
Thanks in advance.
If you have the group of contacts in a
ArrayList
series:If it were some kind of collection that doesn't have a similar method, you can iterate looking for the value like this: