????4.????????
????????????????飬??????????????????????????????????????????????????????????????????????á?
class Cat
{
double weight;
int age;
public Cat(double weight ?? int age)
{
this.weight = weight;
this.age = age;
}
}
public class ArrayTest
{
public static void main(String[] args)
{
// ???壬?????????????int[]????
int[] pos = new int[5];
// ????????????????????
for (int i = 0; i < pos.length ; i++ )
{
pos[i] = (i + 1) * 2;
}
// ????pos??????????????????????????????????
// ???漴????????????????int??????
// ????int??????????????????
int a = pos[1];
int b = 20;
pos[2] = b;
// ???壬?????????????Cat[]????
Cat[] cats = new Cat[2];
cats[0] = new Cat(3.34?? 2);
// ??cats??????1???????????c1??
Cat c1 = cats[0];
Cat c2 = new Cat(4.3?? 3);
// ??c2???????cats??????2?????
cats[1] = c2;
}
}
?????????????У??????????????????

????5.???????
???????? int ???????? [] ???????????????????? int[] ??????????????????????? [] ?? int[][] ???????????????????????ν???????飬????????????????????飬??N????飬??????????N-1???????????顣
?????????????
????int[][] a = new int[4][];
????a[0] = new int[2];
????a[0][1] = 6;
???????????????

??????????????????????飬??6?????????????????????????顣
??????????????????????顣