// Fig. 7.5: InitArray.java // initialize array n to the even integers from 2 to 20 import javax.swing.*; public class InitArray { public static void main( String args[] ) { final int ARRAY_SIZE = 10; int n[]; // reference to int array String output = "";
n = new int[ ARRAY_SIZE ]; // allocate array
// Set the values in the array for ( int i = 0; i < n.length; i++ ) n[ i ] = 2 + 2 * i;