I want to declare an array in a base class but instantiate it only in subclasses. I need to do stuff like get the length of this array in base class but it's coming up as null. I only need to instantiate subclasses. Can I do this someway? Thanks for any help in advance...
public class A {
protected int[] array;
public void someMethod() {
variable = array.length;
}
}
public class B extends A {
public void doSomething() {
array = new int[] { 1,2,3 };
}
}
nulluntilB.doSomethingis called. After that, it would no longer benull.