黑马程序员技术交流社区
标题:
求解释
[打印本页]
作者:
张雪萍
时间:
2013-5-7 11:13
标题:
求解释
本帖最后由 张雪萍 于 2013-5-8 22:13 编辑
int [] a1 = new int[3];
int [] a2 = new int[4];
int[][] a3 = new int[2][3];
String [] a4 = new String[]{"a","b","c"};
System.out.println(a1.getClass() == a2.getClass());
System.out.println(a1.getClass()==a3.getClass());
System.out.println(a1.getClass() == a4.getClass());
复制代码
这是什么错误啊
iMultiple markers at this line
- Incompatible operand types Class<capture#8-of ? extends int[]
> and Class<capture#9-of ? extends int[][]>
- Incompatible operand types Class<capture#8-of ? extends int[]
> and Class<capture#9-of ? extends String[]>
Incompatible operand types Class<capture#8-of ? extends int[]> and Class<capture#9-of ? extends int[][]>
作者:
小石头39910
时间:
2013-5-7 11:52
貌似是二维数组和String定义的数组不能继承01.int [] a1 = new int[3];
作者:
黄玉昆
时间:
2013-5-7 21:35
你这个是不是编译的时候就报错了啊,如果你真想这么比较的话,还不用equals比较的,那么建议你用Object强转一下,再比较。如
System.out.println(((Object)a1.getClass()) == a2.getClass());
你试试,应该没问题了
作者:
张雪萍
时间:
2013-5-8 00:03
黄玉昆 发表于 2013-5-7 21:35
你这个是不是编译的时候就报错了啊,如果你真想这么比较的话,还不用equals比较的,那么建议你用Object强转 ...
好嘞,走着呢
作者:
黄玉昆
时间:
2013-5-8 21:07
如果问题解决了,请将分类改为“已解决”,谢谢
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2