interface是创建接口的语法
implements是使用接口的语法
例如:
创建一个接口:
public interface attack{
void shoot();//默认为抽象类,不能以{}结尾,只能以()结尾
}
创建一个类使用接口:
public soldier implements attack{ //写具体的实现方法
public void shoot(){
System.out.println("士兵射击");
};
}
而extends是继承父类的方法,可以直接使用
例如:
public class kid{
void cry{
System.out.println("呜呜呜呜呜");
}
public class baby extends kid { public static void main(String[] args) { kid a = new kid(); a.cry(); } }