Given below code is giving null pointer exception at
public class Testing {
public static final String HD_DATA = "STOCK,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10";
public static final String HD_DATA_1 = "1,10,20,30,40,50,60,70,80,90,100";
public static final String HD_DATA_2 = "2,11,22,33,44,55,66,77,88,99,111";
public static void main(String[] args) {
String[] hdDataArray = HD_DATA.split(",");
String[] hdDataArray1 = HD_DATA_1.split(",");
String[] hdDataArray2 = HD_DATA_2.split(",");
String[][] pram = new String[3][]; //[null, null, null]
for(int i=0;i<3;i++) {
for(int j=0;j<hdDataArray.length;j++) {
if(i ==0) {
pram[i][j] = hdDataArray[j]; // Exception in thread "main" java.lang.NullPointerException
}
else if (i ==1){
pram[i][j] = hdDataArray1[j];
} else if(i == 2) {
pram[i][j] = hdDataArray2[j];
}
}
}
System.out.println(pram);
}
}
Null pointer exception generate while trying to give but i would like to insert the data at the run time is there any way to we can insert data in array of arrays at runtime identify the size of arrays of array like jagged array