0
whats wrong , please tell me.
6 Answers
+ 9
It'll be good to have another field called name. Something like this?
https://code.sololearn.com/ciX9y63IpY75/?ref=app
+ 8
this.Animali = eats;
What is Animali here?
Also, method return type cannot be void and String together.
+ 6
1. When we use the keyword "this", it's expected to have a data field after that. Like this.name, this.legs etc. are correct. But since Animali is not a field, this.Animali will cause error.
2. conflicting return type
3. You passed the String "Dog" as method argument and set it as Animali which doesn't exist.
I've re-written your code using Animali. But it's always a good practice to set data fields using setter or constructor.
https://code.sololearn.com/cvVOwp09gDgW/?ref=app
+ 2
thank you, thats what i wanted to do, but what was wrong in my code?
+ 1
i just tried to figured out the error, changing the name several times. i want to animal gets the string dog in main and then prints with ( string + "eats")
+ 1
thanks đđ