0
I’m doing a class exercise Carro
and subclasses Familiar
Citadino
and Jipe
... Only by making a class Testabuzinar1
which instantiates each of the subclasses and then calls the horn method (which is in the class Carro
) and I get a mistake
Cannot make Astatic Ference to the non-static field...
Follow the code of the Forehead horn 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();
}
}
Or includes instances of classes in the method
main
, making them local.– Woss
@Andersoncarloswoss had forgotten that possibility
– user28595
Thanks for your help
– Rita