最佳答案
如何检查一些类是否实现了接口? 当有:
Character.Gorgon gor = new Character.Gorgon();
如何检查 gor是否实现了 Monster接口?
public interface Monster {
public int getLevel();
public int level = 1;
}
public class Character {
public static class Gorgon extends Character implements Monster {
public int level;
@Override
public int getLevel() { return level; }
public Gorgon() {
type = "Gorgon";
}
}
}
Gorgon中重写的方法 getLevel()是否正确,以便返回新创建的 gor的 level?