int[] a = {3, 7, 1, 9, 4};
int target = 100;
int idx = -1;
for (int i = 0; i < a.length; i++) {
if (a[i] == target) { idx = i; break; }
}What is idx after the loop?
- Acheck_circle
-1
- B
4
- C
5
- D
0
Explanation
Target 100 is not in the array, so idx remains its initial value of -1.