When you call the get()
method of an ArrayList
, you are asking the computer to return the element (Node1
object) at an index (location). ArrayList
s are 0-indexed, so nodes1.get(109)
tries to return the non-existent 110th element, hence the IndexOutOfBoundsException
.
One thought is to add()
your Node1
objects in order and let their indices serve as id’s. Another is to check out HashMap
s in the Processing reference.