补充点:

1.每个数组都有一个 length属性值;length的属性是 public   final    int

顾名思义:

1.1.所以数组一旦常见就不能修改

1.2.常见数组时必须声明其长度

2.int a[]=new int[3];

变量a就是一个引用,指向生成的数组对象的首地址

 

附上练习代码君(有三维数组彩蛋>,<):

package com.jacob.javase;


/*
 * 数组的详细探讨2:
 */
public class ArrayTest12 {
public static void main(String[] args) {
Person[] p = new Person[3];
Person[][] p1 = new Person[2][3];


int[][] a = new int[2][3];


// 探讨存储的值
// System.out.println(a[0] instanceof int[]);
// System.out.println(a instanceof int[][]);


// System.out.println(p[1] instanceof Person);
// p[1] = new Person(12);
// System.out.println(p instanceof Person[]);


// System.out.println(p1[0][1] instanceof Person);
// System.out.println(p1[0] instanceof Person[]);
// System.out.println(p1 instanceof Person[][] );
// 三维数组
int[][][] a1 = new int[2][3][4];


// System.out.println(a1 instanceof int[][][]);
//
// System.out.println(a1[0] instanceof int[][]);
//
// System.out.println(a1[0][0] instanceof int[]);


for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
for (int k = 0; k < a1[i][j].length; k++) {
a1[i][j][k] = 100;
}
}
}
// printThreeDimension(a1);
}


// 三维数组遍历
public static void printThreeDimension(int a[][][]) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
for (int k = 0; k < a[i][j].length; k++) {
System.out.print(a[i][j][k] + " ");
}
System.out.println(" two ");
}
System.out.println(" one ");
}
}
}


class Person {
int age;


public Person(int age) {
this.age = age;
}
}