public static int findMax(int[] arr) {
int max = 0;
for (int i = 0; i < arr.length; i++) {
if (arr[i] > max) {
max = arr[i];
}
}
return max;
}
This method returns the maximum element of any integer array.
Your task:
Is the claim correct?
If not:
1. Give me a counterexample.
2. Explain exactly why the code fails.
3. Tell me the minimum change needed to fix it.
This is a basic Java problem, so give me your reasoning.