SO I have the following code
public void rand(int N){
double[]x=new double[N];
double[]y=new double[N];
double[][]res=new double[N][N];
for(int i=0;i<N;i++){x[i]=random.nextDouble();y[i]=random.nextDouble();}
}
but the it would return the nullpointerexceptionerror on the for loop….can anybody tell me what’s wrong with it?
Where did you initialize random? I don’t see it.
You’ll have another problem: the x and y arrays and the res matrix are declared, initialized, and immediately go out of scope when you leave the method. All that work is wasted.
I’d think about it more like this: