Answer:
for ( int index=0; index <x.length; index++ )
if ( x[index] > max )
max = x[index] ;
Using the Method
Here is how our new method is used by a main() program.
Notice that an ArrayOps object must be created before
the method can be used.
class ArrayDemo
{
public static void main ( String[] args )
{
int[] ar1 = { -20, 19, 1, 5, -1, 27, 19, 5 } ;
ArrayOps operate = new ArrayOps(); // create an ArrayOps object
int biggest = operate.findMax( ar1 ); // call findMax() with a reference to the array
System.out.println("The maximum is: " + biggest );
}
}
The program defines a class called ArrayDemo.
ArrayDemoholds the staticmain()method.main()creates an array object,ar1main()creates anArrayOpsobject,operate.- The
findMax()method of theArrayOpsobject is called with a reference to the array objectar1as a parameter.
QUESTION 4:
What, exactly, is ar1 ?