Getting Arraylist IndexOutOfBoundsException

The index of the first element is 0. The size of the collection is a number which is one more than the last index. E.g, if the collection is of size 5, the last index is 4. What you probably want to do is this:

idx = transactions.get(row).size() - 1;

Curious about why indexing starts at 0? Read this fine article by Dijsktra: http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html

Leave a Comment