instanceof
을 사용하여 사용자 정의 인터페이스에 대해 사용자 정의 클래스를 테스트 할 수 있으며 Java 핵심 클래스와 동일한 작업을 수행 할 수없는 이유는 무엇입니까?customof/core 클래스가있는 instanceof
interface A{}
class B{}
public class Tmp {
public static void main(String [] args) {
String s = "";
Integer i = 1;
B b = new B();
System.out.println(s instanceof A); //1
System.out.println(i instanceof A); //2
System.out.println(b instanceof A); //3
}
}
줄 1과 2는 컴파일되지 않습니다. 3 행은 컴파일되고 (false
을 인쇄하십시오.) 차이점이 뭐야?
[this] (http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html) 기사를 읽으셨습니까? – Bernard
@Bernard, 예, 읽었습니다. 그것은 내 질문에 대답하지 않았다. –