For a project in Java I want to create a private reference to an array in a superclass, but do not implement it. I want to do the implementation in the childclass, so I created a getter method for that array in the superclass. In the childclasses constructor, I implement the array and now the problem is, that the array reference in the superclass stays null even if I added an array to the reference. I want to use the array later in the superclass. I will add some code for better understanding.
I understand my fault that this is not easily possible in Java like this, but is there any solution to "edit" the array like this by it's reference or do I have to do this with a setter method?
//parent class
public abstract class Superclass {
private Test[] test_Values;
public Measurement[] getTestValues() {
return this.test_Values;
}
}
//child class
public class ChildClass extends SuperClass {
public ChildClass() {
Test[] measures = super.getTestValues();
measures = new Test[4];
}
}