Salve a tutti!
mi aiutate a capire l'errore di compilazione che si verifica compilando questo codice?:
A.java:15: error: constructor Plant in class Plant cannot be applied to given types;codice:class Plant { String family; protected Plant(String f){ family = f; } protected void stampa() { System.out.println("Plant: "+ family); } } class Tree extends Plant { public Tree(String f){ super(f); } public Tree(){} public void stampa() { System.out.println("Tree: "+ family); } public static void main(String[] args){ Plant a = new Tree("Olive"); a.stampa(); } }
public Tree(){}
^
required: String
found: no arguments
reason: actual and formal argument lists differ in length
1 error
Il codice non è mio ma fa parte di un test sul quale mi sto esercitando...
c'erano anche altri errori che sono riuscito a correggere ma questo mi sfugge il problema :/
Qualcuno può aiutarmi? ringrazio in anticipo!

Rispondi quotando