I appreciate there are a lot of problems with this error, particularly amongst newbies, but this one really is confusing me.
The above is intended to create a new ArrayList with 10,000 indices. In a method later on the following statement attempts to execute:
public class StockManager
private ArrayList<String> database = new ArrayList<String>(10000);
product.id is an integer, and product.details is a string. If my understanding of an ArrayList's add method is correct, the two parameters determine the index of the ArrayList element that data is to be added to, and then the data to be added.
When the above statement is reached in the method call, I get the error "IndexOutOfBoundsException: Index: 3055, Size: 0 (in java.util.ArrayList)" (product.id is equal to 3055).
What I don't understand is how can index 3055 be out of bounds when the ArrayList database has indices 0 to 9999? (I have double-checked that this is the case using the Object Inspector in my IDE.) If anyone can offer even the most painfully obvious fixes, I'd be very grateful.