int[] a = {1, 2, 3, 4};
for (int i = 0; i < a.length - 1; i++) {
a[i] = a[i + 1];
}
System.out.println(a[0]+" "+a[1]+" "+a[2]+" "+a[3]);What is printed?
- A
1 1 2 3
- B
2 3 4 0
- C
1 2 3 4
- Dcheck_circle
2 3 4 4
Explanation
Each element is replaced by the one to its right; the last element is unchanged. After the loop: 2, 3, 4, 4.