Bael-5125 Java implicit super constructor is undefined error (#11566)

Co-authored-by: Sachin kumar <sachin.n.kumar@oracle.com>
This commit is contained in:
sachin 2021-12-14 07:48:00 +05:30 committed by GitHub
parent 9f418cd996
commit 53b9df34a2
2 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,26 @@
package com.baeldung.implicitsuperconstructorundefined;
public class Employee extends Person {
private Double salary;
public Employee(String name, Integer age, Double salary) {
// comment this super call to see the error.
super(name, age);
this.salary = salary;
}
public Employee(Double salary) {
super();
this.salary = salary;
}
public Double getSalary() {
return salary;
}
public void setSalary(Double salary) {
this.salary = salary;
}
}

View File

@ -0,0 +1,35 @@
package com.baeldung.implicitsuperconstructorundefined;
public class Person {
private String name;
private Integer age;
public Person(String name, Integer age) {
this.name = name;
this.age = age;
}
// comment this constructor to see the error.
public Person() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}