instanceof 연산자1 JAVA instanceof 연산자 [코딩백과 with JAVA] instanceof 연산자instanceof 연산자는 객체가 특정 클래스, 서브클래스, 또는 특정 인터페이스를 구현한 클래스의 인스턴스인지 확인하는 데 사용됩니다. 이는 객체 지향 프로그래밍에서 객체의 타입을 런타임에 확인할 때 매우 유용합니다.사용 형식:public class InstanceofExample { public static void main(String[] args) { Animal animal = new Dog(); Dog dog = new Dog(); Cat cat = new Cat(); System.out.println("animal instanceof Animal: " + (animal instanceof Animal)); .. 2024. 12. 21. 이전 1 다음