int[] a = {10, 20, 30, 40};
for (int i = a.length - 1; i >= 0; i--) {
System.out.print(a[i] + " ");
}What is printed?
- A
10 20 30 40
- Bcheck_circle
40 30 20 10
- C
ArrayIndexOutOfBoundsException
- D
40 30 20 10
Explanation
Iterating from i = a.length-1 down to 0 prints elements in reverse order.