The error I am getting: Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 11 out of bounds for length 6
In the project I have to do I have to be able to add and delete from a table certain values which completely work. However I want to make my 2D ArrayList able to have a set value of 6 (width) and 6 (length) but be able to add objects out of range, example addToTable(x, y) - > addToTable(7, 7) without it erroring.
variable:
ArrayList<ArrayList<My2DTableCoordinate>> coordinates
function:
private boolean checkIfInRange(int x, int y) {
if (x < coordinates.get(x).size() && y < coordinates.get(y).size()) {
return true;
}
return false;
}
this is given that
int width = 6;
int height = 6;
x being width, y being height