J Doyle wrote:Thanks for the reply, I realised this a few minutes ago, so I made a new method in the nodeArray class:
You need to understand the difference between the size and the capacity of an Arraylist.
The size is the number of elements it currently contains - you can only add a new value to an Arraylist when index >= 0 and index <= size.
The capacity is the size of the array that the ArrayList uses in the background to store values, but it only uses contiguous elements of the array i.e. a value cannot be added to element 4 of the array until values have been added to elements 0 - 3.