Can anybody explain, why do I have to use this code pattern?
// Create the array to store the CDs.
CD[] cdLibrary = new CD[20];
// Populate the CD library with CD objects.
for (int i=0; i<20; i++)
{ cdLibrary[i] = new CD(); }
I cannot understand why the initialization of objects in an array does not occur when I call new CD[20]
. It seems like I'm writing excess code. Can one of these steps be skipped?