I'm currently learning java, and im having a problem understanding what's going on when we use a constructor when inheriting from a class that already has a constructor.
The best would be to just throw in my example. I have 2 classes, "Person" and "Employee". "Employee" is inheriting from "Person", and the following is the code from each of their respective constructors:
This is the constructor for "Person" class:
===========================================
public Person(String name, String surname, int age, String nationality) {
this.name = name;
this.surname = surname;
this.age = age;
this.nationality = nationality; }
This is the constructor for "Employee" class, which is inheriting "Person"
===========================================================================
public Employee(String name, String surname, int age, String nationality, String qualification, String position, double rateOfPay, int hoursWorked){
super(name, surname, age, nationality); // <-------------Not understanding
this.qualification = qualification;
this.position = position;
this.rateOfPay = rateOfPay;
this.hoursWorked = hoursWorked;
displayEmployeeDetails();
}
What im not understanding is the line i marked with an arrow where there is the super(name, surname, age, nationality) line. Can anyone explain please?