go to previous page   go to home page   go to next page

Answer:

String[] strArray = new String[8] ; 

. . . .

strArray[ strArray.length-1 ] = "the end" ;

Writing a String to the Monitor

Here is a fragment that writes out the first two Strings to the monitor:

System.out.println( "cell 0: " + strArray[0] );
System.out.println( "cell 1: " + strArray[1] );

Nothing unusual here. Each array cell contains a String reference that can be used in the usual ways. Here is a fragment that writes each cell's String (if there is one) to the monitor :


String[] strArray = new String[8] ;  // combined statement

. . . . .

for (int j=0; j   strArray.length; j++ )
{
  if ( strArray[j] !=  )
    System.out.println( "cell " + j + ": " + strArray[j] );
  else
    System.out.println( "cell " + j + ": " + "empty" );
}

QUESTION 6:

Fill in the blanks.


go to previous page   go to home page   go to next page