I have this child class:
class ChildClass {
public class Room{
int size;
public void On(int size){
this.size = v;
}
}
public Room[] ar;
}
And I try to initialize ar in my main method:
public class JavaOnlineCompiler {
public static void main(String args[]) {
ChildClass cc = new ChildClass();
ChildClass.ar = cc.new Room[]{ //attempt to initialize arr
new Room(10), new Room(29)
};
}
}
But it isn't working this way. What am I doing wrong?
I am referring to ar inside methods of ChildClass which is why I don't want to define the array outside of ChildClass.