Java Reference
In-Depth Information
this.isCurved = isCurved;
}
public String getmaterial() {
return material;
}
public void setmaterial(String material) {
this.material = material;
}
}
Next, look at the subclass of HockeyStick : a class named WoodenStick .
public class WoodenStick extends HockeyStick {
public static final String material = "WOOD";
public int lie;
public int flex;
public WoodenStick(int length, boolean isCurved){
super(length, isCurved, material);
}
public WoodenStick(int length, boolean isCurved, int
lie, int flex){
super(length, isCurved, material);
this.lie = lie;
this.flex = flex;
}
}
How It Works
Object inheritance is a fundamental technique in any object-oriented language. Inherit-
ing from a base class adds value because it allows code to become reusable in multiple
places. This helps to make code management much easier. If a change is made in the
Search WWH ::




Custom Search