如何检查某个类是否实现了接口?当有:
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创建的?