I'm doing an exercise with a class Carro
and subclasses Familiar
Citadino
and Jipe
... Only when doing a class Testabuzinar1
that instantiates each of the subclasses and then calls the method honk (which is in class Carro
) and an error appears to me
Can not make astatic reference to the non-static field ...
Follow the code of the Testa buzina class
public class TestaBuzinar1 {
public Citadino citadino = new Citadino(); //ou Citadino citadino=new citadino()
public Familiar familiar = new Familiar();
public Jipe jipe = new Jipe();
public static void main(String[] args) {
citadino.buzinar();
familiar.buzinar();
}
}