In Java, is it possible to override member data in a subclass and have that overridden version be the data used in a super class\'s implementation?
In other words, here\
This way you are hiding the parent variable stuff with the defined stuff.
Try giving value to stuff in the initialization block (or in the constructor):
abstract public class BasicStuff {
protected String[] stuff;
{
stuff = new String[] { "Pizza", "Shoes" };
}
public void readStuff() {
for(String p : stuff) {
System.out.println(p);
}
}
}
..
public class HardStuff extends BasicStuff {
{
stuff = new String[] { "Harmonica", "Saxophone", "Particle Accelerator" };
}
}