如题:
int[] arr = new int[3];
int[][] arr = new int2;
Integer[] arr = new Integer[3];
Integer[][] arr = new Integer2;
以上语句分别会产生多少个对象?
public class ArrayListDemo {
public static void main(String[] args) {
int[] arr1 = new int[3];
int[][] arr2 = new int[2][3];
Integer[] arr3= new Integer[3];
Integer[][] arr4 = new Integer[2][3];
if(arr1 instanceof Object){
System.out.println("true");
}
if(arr2 instanceof Object){
System.out.println("true");
}
if(arr3 instanceof Object){
System.out.println("true");
}
if(arr4 instanceof Object){
System.out.println("true");
}
}
}
全部打印出true。说明在java中间,数组就是一个Obejct对象。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。