Dziedziczenie – problem z super();

0

Cześć
Staram się zrozumieć dziedziczenie, natomiast mam problem ponieważ kompilator wyświetla mi :

Error:(4, 14) java: call to super must be first statement in constructor

jak dla mnie wszystko powinno być dobrze może ktoś mnie uświadomi co jest nie tak.

public class Human {

    private String imie;
    private String klasa;
    private int str;

    public void Human(String imie, String klasa, int str) {

        this.imie = imie;
        this.klasa = klasa;
        this.str = str;

    }
}

public class Elf extends Human {
    private int agi;

    public void Elf(String imie, int str, int agi){
        super(imie,"Elf",str);
        this.agi=agi;
    }
}
3

To

public void Elf(String imie, int str, int agi){

nie jest konstruktor. Zmień na

public Elf(String imie, int str, int agi){

Analogiczną poprawkę wprowadź w klasie Human.

1 użytkowników online, w tym zalogowanych: 0, gości: 1