使用isInstanceOf()测试对象类型
2008-05-24 00:35
387 查看
google_ad_client = "pub-8800625213955058";
/* 336x280, 创建于 07-11-21 */
google_ad_slot = "0989131976";
google_ad_width = 336;
google_ad_height = 280;
//
在Java中,有时候你需要基于一个对象的类型来做一些判断。用关键字instanceof很容易办到。比如:
if ( object instanceof java.lang.String )
{ System.out.println("true");}
但是,如果在编译时你还不知道对象的类型,怎么办?标准API提供了java.beans.Beans类,它可以让你在运行时动态测试对象的类型。
java.beans包还提供了很多类,可以帮助你实现自检﹑实例化﹑检查bean的运行环境等。你可以连接到 JavaBeans documentation,来查看更多类的使用。
/* 336x280, 创建于 07-11-21 */
google_ad_slot = "0989131976";
google_ad_width = 336;
google_ad_height = 280;
//
在Java中,有时候你需要基于一个对象的类型来做一些判断。用关键字instanceof很容易办到。比如:
if ( object instanceof java.lang.String )
{ System.out.println("true");}
但是,如果在编译时你还不知道对象的类型,怎么办?标准API提供了java.beans.Beans类,它可以让你在运行时动态测试对象的类型。
java.beans包还提供了很多类,可以帮助你实现自检﹑实例化﹑检查bean的运行环境等。你可以连接到 JavaBeans documentation,来查看更多类的使用。
相关文章推荐
- Flex的四种判断对象类型的方式 as instanceof is typeof比较
- Python isinstance判断对象类型
- oracle 大对象(lob)类型使用性能测试
- isInstanceOf与类型擦除
- java运行报错:nested exception is java.lang.NoSuchFieldError: INSTANCE,但使用@Test测试是好的
- Python isinstance()判断对象类型
- JS中isPrototypeOf 和hasOwnProperty 的区别 ------- js使用in和hasOwnProperty获取对象属性的区别
- js 原始类型 内置对象 protype instanceof construcor Object.prototype.toString.call()
- 第十四章 类型信息RTTI Class instanceof isInstance
- 使用反射报异常:object is not an instance of declaring class解决方案
- js中判断一个对象的类型的方法typeof/constructor/instanceof
- CLisp 11:使用 type-of 确定对象的类型
- [9-27下午]6.使用is运算符测试类型的兼容性
- 内部类的使用问题No enclosing instance of type Outer is accessible. Must qualify the allocation with an enclo
- oracle 大对象(lob)类型使用性能测试
- 使用内部类时提示No enclosing instance of type E is accessible. Must qualify the allocation with an enclosing
- Python isinstance判断对象类型
- javascript instanceof、isPrototypeOf、hasOwnProperty、in的使用
- as3数据类型检查写法(is/as/typeof/in/instanceof)用法介绍
- Python isinstance() 函数 判断对象类型