`
luzl
  • 浏览: 578212 次
  • 性别: Icon_minigender_1
  • 来自: 大连
社区版块
存档分类
最新评论

Java 子类的 instanceof 父类

    博客分类:
  • Java
阅读更多
package scjp;

class Parent{
	
}
public class Demo57 extends Parent{

	public static void main(String[] args) {
		Demo57 demo57=new Demo57();
		if (demo57 instanceof Parent) {
			System.out.println("demo57 is the instance of Parent");
		}
	}
	
}

输出为demo57 is the instance of Parent,说明子类是父类的实例.instanceof返回的是true
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics