Question: COP 2800 Java Programming - Module 8 (Chapter 13 and 15) Assignment - Exercise 20862 The elements of an integer -valued array can be set
COP 2800 Java Programming - Module 8 (Chapter 13 and 15) Assignment - Exercise 20862
The elements of an integer -valued array can be set to 0 (i.e., the array can be cleared) recursively as follows:
An array of size 0 is already cleared;
Otherwise, set the last of the uncleared elements of the array to 0, and clear the rest of the array
Write a void method named clear that accepts an integer array , and the number of elements in the array and sets the elements of the array to 0.
---------
I tried using this code but got an error message as show in screenshot below it:
public void clear(int array, int length) {
if (length == 0) return;
array[0] = 0;
clear(array+1, length-1); }

CODELAB ANALYSIS: COMPILER ERROR(S) More Hints: I haven't yet seen a correct solution that uses: Want More Hints? Click here COMPILER ERROR MESSAGES CTest.java :9: error: array required, but int found array[0] 0; 1 error 1 class CTest 3 public void clear (int array, int length) 4 if (length 0) return 10 arra 0; 12 13 clear ray 1, length-1 15 16
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
