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:
parent
9f418cd996
commit
53b9df34a2
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user