public class Conversions {
public static void main(String[] args) {
int index = 3;
int[] arr = new int[] { 10, 20, 30, 40};
arr[index] = index = 2; //(1)
System.out.println("" + arr[3] + " " + arr[2]);
}
}
I have this and it gives:
2 30
I was hoping it will give
40 2
At (1) Why was the value of the index in assignment not changed to 2 ( and kept as 3). ?