instanceof1 [Java] instanceof vs isInstance() instanceof과 isInstance()모두 객체의 클래스를 확인하는데 사용합니다. 하지만 클래스의 체크 시점이 정적(컴파일 타임)이냐 동적(런타임)이냐의 차이를 보입니다. 즉, instanceof는 컴파일타임에 타입 에러를 체크하고, isInstance()는 런타임에 타입 에러 체크를 합니다. isInstance() 사용 예 // Java program to demonstrate working of isInstance() // method public class Test { // This method tells us whether the object is an // instance of class whose name is passed as a // string 'c'. public static bo.. 2021. 3. 11. 이전 1 다음