int[] a = {1, 2, 3, 4};
int temp = a[0];
a[0] = a[3];
a[3] = temp;
System.out.println(a[0] + " " + a[3]);What is printed?
- Acheck_circle
4 1
- B
1 4
- C
1 1
- D
4 4
Explanation
Standard swap pattern: save a[0] in temp, copy a[3] into a[0], then copy temp into a[3]. Result: a[0]=4, a[3]=1.