// Allocating an array of JLabel Objects. // STAGE 1: Allocate space for 30 pointers, indexed 0..29, and set pointers to null // Java does NOT set slots to newly minted JLabel objects. JLabel[] labs = new JLabel[ 30 ]; // Verify Java indeed sets pointers to null, not to JLabels. assert labs[ 2 ] == null : "The sky is falling. Java failed to initialize to null"; // STAGE 2: Make the pointers point to real objects. // You can do it one by one. labs[ 0 ] = new JLabel( "hello" ); // You can point to prexisting JLabels. labs[ 1 ] = anOldJabel; // Or initiaalise with a loop. for ( int i=0; i<labs.length; i++ ) { labs[ i ] = new JLabel( "Heartfelt greetings clone number " + i ); }