-5
/** * 2016/10/15에 zhangzhongzheng 작성. */자바 상속에 관하여
공용 클래스 ExtendsTest {
static Dog d = new Dog();
public static void main(String[] args) {
Animal a = d;
System.out.println(a instanceof Animal);//true
System.out.println(a instanceof Dog);//true
System.out.println(d instanceof Animal);//true
System.out.println(d instanceof Dog);//true
}
static class Animal {
}
static class Dog extends Animal {
}
}
왜 모든 사실 ??????
는 슬랩이되어야한다고 여기에 세 가지가 있습니다 당신이 약간의 시간을내어 ['instanceof']를 조사한다면 당신은 너무나 명백한 얼굴이고 다른 하나는 너무 큽니다. (http://stackoverflow.com/questions/7313559/what-is-the-instanceof-operator-used- 를 위해) 또는 다만 천천히 이름을 고려하십시오. – ChiefTwoPencils