I want to fill a table with in 1st row the index and in 2nd row an element generated on a uniform law. To follow the steps of my work I did a non-executable file:
import java.util.Random;
public class CSignal {
private int N, V;
private double[][] tabSig;
public double k;
public CSignal() {
V = 4;
N = 10;
Remplit();
}
public void Remplit() {
for (int i = 0; i < N; i++) {
tabSig[0][i] = i;
Random e = new Random();
k = e.nextDouble();
tabSig = new double[2][2];
this.tabSig[1][i] = k * V;
}
}
public int get_N() {
return N;
}
public int get_V() {
return V;
}
public double[][] get_tab() {
return tabSig;
}
public void Affiche() {
System.out.println(tabSig);
}
}
and then the executable:
public class TP {
public static void main(String[] args) {
// TODO Auto-generated method stub
CSignal signal;
signal = new CSignal();
signal.Affiche();
}
}
When i try this prog I got the following error:
Exception in thread "main" java.lang.NullPointerException: Cannot load from object array because "this.tabSig" is null