Swears an error on extends , according to the book everything should work. What is the problem?

MISTAKE:

Error: (37, 1) java: constructor Person in class com.company.Person cannot be applied to given types; required: java.lang.String

 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); Person Papich = new Person("Vitaliy"); Papich.display(); } } 
 class Person { private String name; public String getName() { return name; } public Person(String name) { this.name = name; } public void display() { System.out.printf("Name : %s", name); } } 
 class rabotyaga extends Person { private String Zavod; } 

    1 answer 1

    You have a constructor with a parameter in the superclass. Therefore, when you extend a class, you must create a constructor that calls the superclass constructor with a parameter.

     class rabotyaga extends Person { private String Zavod; public rabotyaga(String name){ super(name); } } 
    • Yeah, really. Dzyakuyu! - Genius