一维数组和二维数组不是同一类型的,不能比较,下面是测试代码你可以自己入到main方法里测试下下- @Test
- public void test7 (){
- int [] a = new int []{1,2,3,};
- int [][]b = new int[2][3];
- int [] c = new int []{1,4,3,};
- System.out.println(a.getClass()+" | "+b.getClass()+" | "+c.getClass());
- boolean m = a.getClass().isInstance(b);
- boolean n = a.getClass().isInstance(c);
- System.out.println(m+"|"+n);
- }
复制代码 结果- class [I | class [[I | class [I
- false|true
复制代码 |