If you enter the value 2, then it produces the following exception:
2
Index: 1, Size: 0
Index 1 out of bounds for length 0
So what index is it complaining about? A look at the code shows the following at the beginning of the
buildDimArray
method:
dimBaseArray.add(dimBase-1, new ArrayList<String>());
Note here that
dimBase
is equal to 2, so
dimBase-1
equals 1. But
dimBaseArray
contains no entries yet so it fails, because you cannot add an entry at index 1, until you have added an entry at index 0.
Incidentally, if you had provided the output details in your original question it may have led us to the answer sooner.