I have a object which contains an array of doubles.
public class NumberRow {
static final int MAX_AMOUNT_OF_NUMBERS = 2500;
double[] NumberArray = new double[MAX_AMOUNT_OF_NUMBERS];
NumberRow(double[] NumberArray){
this.NumberArray = NumberArray;
}
}
In my main program I start with creating a array of the object NumberRow in the constructor like this
NumberRow[] numberRow;
later in the program I put this code:
numberRow = new NumberRow[dataset.numberOfVariables];
After that I call a function which gives value to an numberRow:
double misc = in.nextDouble();
numberRow[k].NumberArray[i] = misc;
I did say where NumberRow is pointing to. However, eclipse gives me a null pointer pointer exception on this line:
numberRow[k].NumberArray[i] = misc;
I hope anyone can see what I did wrong? Thank you :)!
double[] NumberArray = new double[MAX_AMOUNT_OF_NUMBERS];is never used because you reallocate it in the constructor:this.NumberArray = NumberArray;. Are you sure that is what you intended?NumberRow[] numberRow;isn't a constructor. It doesn't "create" anything.