ArrayOps.printRange( ar1, 3, 3);
This will print out element 3 of the array, the value 5.
Here is the ArrayOps class, now including
a new method.
This new method adds up all the elements in
an array.
Here is how the method might be used in main():
class ArrayDemo
{
public static void main ( String[] args )
{
int[] ar1 = { -20, 19, 1, 5, -1, 27, 19, 5 } ;
System.out.println("The sum of elements is: " + ArrayOps.sumElements( ar1 ) );
}
}
The declaration of the method says that it expects a reference to an array of
int as a parameter, and that it will return an
int back to the caller when it is done:
public static int sumElements ( int[] nums )
Fill in the blanks of the sumElements() method.