0
how to fix
interface Animal { public void eat(); } Cat implements { public eat() { System.out.println("Cat eats"); } }
5 Answers
+ 8
it's better to use inheritance than an interface , always think to abstract your code
https://code.sololearn.com/cmgdrE2k797U/?ref=app
0
Cat implements Animal
In your Cat class add void to the eat method
And in your main method:
Cat c = new Cat();
c.eat();
0
interface Animal {
public void eat();
}
class Cat implements Animal {
public void eat() {
System.out.println("Cat eats");
}
}
0
Class, Animal, Void