本站首页    管理页面    写新日志    退出 [QQ:172832876] [MSN:lanlanq@hotmail.com]
麒麟在天欢迎您

.:日期

«September 2025»
123456
78910111213
14151617181920
21222324252627
282930

.:我的分类

.:最新日志

.:显示信息

blog名称:
日志总数:64
评论数量:34
留言数量:3
访问次数:343146
建立时间:2006年3月10日

.:留言板

.:链接

        公告

在属于自己的一片天空中,敲打着键盘,记录下自己感兴趣和认为自己因该回忆的碎片,可能是财富,也可能是不足,过后你会发现你的进步,这就足够。
[J2EE]instanceof
luckystar 发表于 2008/5/20 14:29:30

instanceof判断一个实例是不是一个类的实例 private static final Throwable Exception = null;  /**  * @param args  */ public static void main(String[] args) {  // TODO Auto-generated method stub  HibernateException he = new HibernateException(Exception);  NestableRuntimeException nre = new NestableRuntimeException();  NestableException ne = new NestableException();  if (nre instanceof Exception) {   System.out.println("NestableRuntimeException is Exception");  }  if (nre instanceof RuntimeException) {   System.out.println("NestableRuntimeException is RuntimeException");  }  if (he instanceof RuntimeException) {   System.out.println("HibernateException is RuntimeException");  }  if (he instanceof Exception) {   System.out.println("HibernateException is Exception");  }    if (ne instanceof Exception) {   System.out.println("NestableException is Exception");  }   } 结果 NestableRuntimeException is ExceptionNestableRuntimeException is RuntimeExceptionHibernateException is RuntimeExceptionHibernateException is ExceptionNestableException is Exception    

阅读全文(2755) | 回复(0) | 编辑 | 精华

 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)
站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.047 second(s), page refreshed 144793222 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号