73.数组类简介
|
![BACKWARD](backward.gif) ![FORWARD](forward.gif) |
- 数组取消了指针算法. 它们使用new 操作符创建:
- 索引从0开始.
- 没有多维数组. 必须使用数组的数组:
- int i[][] = new int[3][4];
- 括号可以跟在数组元素类型后面. 下面的语句是等价的:
- int iarray[];
- int[] iarray;
- byte f(int n)[];
- byte[] f(int n);
- 运行是检查数组边界.
- 数组长度可以使用 .length 获得:
- int a[][] = new int[10][3];
- System.out.println(a.length); // prints 10
- System.out.println(a[0].length); // prints 3
Copyright: NPACT |
![BACKWARD](backward.gif) ![FORWARD](forward.gif) |