Hello :),
is it possible to determine the ArrayList-index of an element inside the ArrayList based on one of its attributes?
In my particular case I have an Object "worker" with the attributes "name" and "worker_id". The worker_id is an ID I get from the database.
Since the first worker-object inside the ArrayList doesn't necessarily start with 0 (and may have gaps), it's not the same ID as the index each element has inside this ArrayList.
Now I want to determine this particular index of a worker-object inside the ArrayList based on its attribute "worker_id". However: since the list can be very long, I'd like to not have to iterate over the worker-ArrayList everytime.
Using a HashMap might be a solution, but I'd like to use an ArrayList if possible, because I normally won't need a key (except in this case).
Any suggestions are welcome!
Thank you in advance, Igor.