Iam creating an array in a class which has no main method like this:
int[][] Allocation = new int[n][3];
Then Iam trying to initialise all the elements to 1 in the constructor:
n is passed in through the constructor(parameter)
for (int row=0; row <= n-1; row++) {
for (int col=0; col <=2; col++) {
Allocation[row][col] = 1; } }
It gives me an error:
java.lang.ArrayIndexOutOfBoundsException: 0
Please Help me out!!!
int[][] Allocation = new int[n][3];
Then Iam trying to initialise all the elements to 1 in the constructor:
n is passed in through the constructor(parameter)
for (int row=0; row <= n-1; row++) {
for (int col=0; col <=2; col++) {
Allocation[row][col] = 1; } }
It gives me an error:
java.lang.ArrayIndexOutOfBoundsException: 0
Please Help me out!!!