| instanceof 能够获得对象和数组的类型,返回值为true或false,如果检测非类和数组类型的变量,则在编译期间会报错。一下是一个instanceof 的例子。 class test
 {
 int a;
 int b;
 public test(int a,int b)
 {
 this.a=a;
 this.b=b;
 }
 }
 class  instancetest
 {
 public static void main(String[] args)
 {
 test a=new test(2,3);
 if(a instanceof test)
 System.out.println("类型符合--引用");
 else
 System.out.println("类型不符合--对象");
 if(new test(1,2) instanceof test )
 System.out.println("类型符合");
 else
 System.out.println("类型不符");
 
 }
 }
 程序输出为     类型符合--引用
 类型符合
 |