[Solved] Finding an object by ID (Java) [duplicate]


Apparently for solving your problem you need a list of all created instances for Person class. You should store that in a static variable, and then search on it. Something like this:

final static allPeople List<Person> = new ArrayList<Person>();

Then you could search on that list with something like this:

...
if (allPeople.contains(aPerson)){
...

solved Finding an object by ID (Java) [duplicate]