You should also know about the IndexOutOfBoundsException. Thrown when trying to access a cell of a table that does not exist. It must first check the specified line (in the stacktrace) that does not attempt to access a nonexistent box (X).
Code:
int [] monTab = new int [20];
for ( int i = 0 ;i < 20 ;i + + )
{
tab[i] = i;
}
System.out. println (tab[20]);
Most commonly, this error comes from the fact that we try to acedia in the last cell of the table without taking into account the fact that the table starts at index 0 and not as one might think.
Bookmarks