public static boolean remove(int\[\] arr, int val) {
boolean found = false;
int i;
for(i = 0; i < arr.length && !found; i++) {
if(arr\[i\] == val) {
found = true;
}
}
if(found) {
for(int j = i; j < arr.length;j++) {
arr\[j - 1\] = arr\[j\];
}
arr\[arr.length - 1\] = 0;
}
return found;
}
For the code above, what will be the content of the variable arr
at the end of execution, if the method is called with the following values for its parameters:
arr = {3,4,4,5,17,4,3,1}
val = 4