I am currently learning about inheritance in Java and I am having a great amount of trouble understanding it, however one of the main things I cant understand is why is it necessary to invocate a superclass constructor in the following example and how does it help? This example is right from Oracle's tutorial for the super(...)
method.
public MountainBike(int startHeight,
int startCadence,
int startSpeed,
int startGear) {
super(startCadence, startSpeed, startGear);
seatHeight = startHeight;
}
What I was thinking originally was that super(startCadence, startSpeed, startGear);
would shorten the code for the parameters in my current constructor and it would simply take the values that were passed in in the parent class and add it to the child class (like this):
public MountainBike(int startHeight) {
...
}
however as I already know that's wrong, and once again brings me to the question of what super(startCadence, startSpeed, startGear);
really does. I would greatly appreciate some form of explanation so a beginner, like me, could actually understand rather than giving me the definition.