直接上代码,举例示意extends与implement的区别
Java extends和implements区别
//define a runner interface
public interface Runner
{
int ID = 1;
void run();
}
//define a interface Animal extends Runner
interface Animal extends Runner
{
void breathe();
}
//define fish class realization the interface of Animal run() && breathe
class Fish implements Animal
{
public void run()
{
System.out.printIn("fish is swimming");
}
public void breath()
{
System.out.printIn("fish is bubbing");
}
}