The filled blanks are below.
The if statement
skips over slots that contain null.
Otherwise, the method tests if slot j of the
array refers to a string that matches target.
In other words,
we want to test if the contents of two strings are equal.
class Searcher
{
// seek target in the array of strings.
// return the index where found, or -1 if not found.
public static int search( String[] array, String target )
{
for ( int j=0; j < array.length; j++ )
if ( array[j] != null )
// do something here with a non-null slot
}
}
class SearchTester
{
public static void main ( String[] args )
{
. . . . . .
int where = Searcher.search( strArray, "Peoria" );
. . . . . .
}
}