I have two class like this:
class test1{
String var1;
String var2;
String var3;
String var4;
arrayX[] array;
public void create(int size){
arrayX[] array = new arrayX[size]
}
}
class test2{
String var5;
String var6;
}
then I have two methods:
void firstMeth(){
test1[] test1obj = new test1[5];
for(int q = 0 ; q <= 5 ; q++){
test1obj[q - 1] = new test1();
}
}
void secondMeth(){
test1obj[0].create(5);
test1obj[0].array[0].var5 = "Hello";
test1obj[0].array[1].var5 = "Super";
test1obj[0].array[3].var5 = "night";
}
The problem is in the method "secondMeth" because when I try to make assignment for example: test1obj[0].array[0].var5 = "Hello";
I get an error : Cannot invoke methos getAt() on null object. Have you got any idea what I'm doing wrong? What should I change?
Thanks in advance!