# An error I nedd help with

• 06-27-2012, 02:21 PM
TheJavaViking
An error I nedd help with
Hey Guys!

So I'm doing my project which I have to do in java.
Its a simulation model that i have to build basically.
So the are new business branches opening and each one of them generate a task at a specific point, this is a given in the form of an array.

This means that in month 1 0 tasks are generated as well as month 2 but in month 3; 2 tasks are generated.
This means that a maximum of 2 tasks are generated in month 3 and no more and so for each month.
But for each task that is generated there is a 42% probability that it will be accepted.

So i thought that i could produce an array per month for the probabilities i.e. 2 tasks 2 probabilities are generated and stored in an array. for month 4; 5 tasks are generated thus 5 probabilites are generated per task.
The tasks that are accepted go into another array. but that is not the problem.

i got it working sort of... but keeps giving me an error which is posted.

Hope someone can help.

I am new to java, perhaps another way to solve this problem?

The error :
at matrix_a.main(matrix_a.java:82)

just named it matix_a

double [][] probabilities = new double[60][];
//month1
probabilities[0] = new double [1]; ----- month and the size
probabilities[0][0] = 0;

//month2
probabilities[1] = new double [1]; ----- month and the size
probabilities[1][0] = 0;

//month3 - month60

/*month3*/ probabilities[2] = new double [2]; ----- month and the size
/*month4*/ probabilities[3] = new double [5];
/*month5*/ probabilities[4] = new double [7];
/*month6*/ probabilities[5] = new double [10];
/*month7*/ probabilities[6] = new double [11];
/*month8*/ probabilities[7] = new double [12];
/*month9*/ probabilities[8] = new double [13];
/*month10*/ probabilities[9] = new double [15];
/*month11*/ probabilities[10] = new double [17];
/*month12*/ probabilities[11] = new double [19];
/*month13*/ probabilities[12] = new double [19];
/*month14*/ probabilities[13] = new double [20];
/*month15*/ probabilities[14] = new double [22];
/*month16*/ probabilities[15] = new double [25];
/*month17*/ probabilities[16] = new double [25];
/*month18*/ probabilities[17] = new double [28];
/*month19*/ probabilities[18] = new double [28];
/*month20*/ probabilities[19] = new double [30];
/*month21*/ probabilities[20] = new double [30];
/*month22*/ probabilities[21] = new double [30];
/*month23*/ probabilities[22] = new double [30];
/*month24*/ probabilities[23] = new double [30];
/*month25*/ probabilities[24] = new double [30];
/*month26*/ probabilities[25] = new double [32];
/*month27*/ probabilities[26] = new double [32];
/*month28*/ probabilities[27] = new double [33];
/*month29*/ probabilities[28] = new double [33];
/*month30*/ probabilities[29] = new double [35];
/*month31*/ probabilities[30] = new double [35];
/*month32*/ probabilities[31] = new double [35];
/*month33*/ probabilities[32] = new double [37];
/*month34*/ probabilities[33] = new double [37];
/*month35*/ probabilities[34] = new double [37];
/*month36*/ probabilities[35] = new double [37];
/*month37*/ probabilities[36] = new double [37];
/*month38*/ probabilities[37] = new double [37];
/*month39*/ probabilities[38] = new double [37];
/*month40*/ probabilities[39] = new double [37];
/*month41*/ probabilities[40] = new double [37];
/*month42*/ probabilities[42] = new double [37];
/*month43*/ probabilities[42] = new double [37];
/*month44*/ probabilities[43] = new double [37];
/*month45*/ probabilities[44] = new double [37];
/*month46*/ probabilities[45] = new double [37];
/*month47*/ probabilities[46] = new double [37];
/*month48*/ probabilities[47] = new double [37];
/*month49*/ probabilities[48] = new double [37];
/*month50*/ probabilities[49] = new double [37];
/*month51*/ probabilities[50] = new double [37];
/*month52*/ probabilities[51] = new double [37];
/*month53*/ probabilities[52] = new double [37];
/*month54*/ probabilities[53] = new double [37];
/*month55*/ probabilities[54] = new double [37];
/*month56*/ probabilities[55] = new double [37];
/*month57*/ probabilities[56] = new double [37];
/*month58*/ probabilities[57] = new double [37];
/*month59*/ probabilities[58] = new double [37];
/*month60*/ probabilities[59] = new double [37];

for (int i = 2; i < probabilities.length; i++){
line 82----- for (int k = 0; k < probabilities[i].length; k++){
probabilities[i][k] = Math.random();
}
}
for (int i = 2; i < probabilities.length; i++){
for (int j = 0; j < probabilities[i].length; i++){
System.out.println(probabilities[i][j]);
}

}

}
}
• 06-27-2012, 02:31 PM
Norm
Re: An error I nedd help with
Quote:

at matrix_a.main(matrix_a.java:82)
There is a variable on line 82 with a null value. Look at line 82, find the variable with the null value and then backtrack in the code to see why that variable does not have a valid non-null value.