Think in java 答案

    技术2022-05-11  123

    阅前声明: http://blog.csdn.net/heimaoxiaozi/archive/2007/01/19/1487884.aspx 

    /****************** Exercise 3 ****************** * Create an array of object references of the * class you created in Exercise 2, but don't * actually create objects to assign into the * array. When you run the program, notice * whether the initialization messages from the * constructor calls are printed. ***********************************************/public class E03_ObjectReferences {  // You can define the array as a field  // in the class ...  E02_OverloadedConstructor[] array1 =    new E02_OverloadedConstructor[5];  public static void main(String args[]) {    // Or as a temporary inside main:    E02_OverloadedConstructor[] array2 =      new E02_OverloadedConstructor[5];  }}

    //+M java E03_ObjectReferences

    **The above code only creates the array, but not the objects that go into the array. Therefore, you won’t see the initialization messages since the E02_OverloadedConstructor objects are never created.


    最新回复(0)