如何检查某个类是否实现了接口?当有:
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";
}
}
}
方法是否getLevel()
被Gorgon
正确覆盖,所以它可以返回level
新gor
创建的?