1>数组的赋值操作符= 其实就是将数组A的引用复制一份给了数组B。数组B操作发生的变化都将会应用到数组A
2>基本类型的数组的初始化是其默认值,对于引用类型来说,创建的数组仅仅是一个引用数组,此时并不会执行任何操作。直到为数组中的元素进行赋值的时候,一系列的初始化动作才会开始。
class Mobile{
Mobile(int marker) {
System.out.println("Mobile(" + marker + ")");
}
}
public class Person {
private Mobile mobile1 = new Mobile(1);
private Mobile mobile2 = new Mobile(2);
private Mobile mobile3 = new Mobile(3);
Person(){
System.out.println("Person()");
}
public static void main(String[] args) {
//此时只是一个引用数组 并没有对其进行初始化的动作
Person[] peoples = new Person[3];
//只有在赋值的时候才会进行初始化
//peoples[0] = new Person();
}
}