This is the code. I tried to solve it, but I can\'t understand how its output is 111111?
public class Test {
public static void main(String[] args) {
int list[] = {1, 2, 3, 4, 5, 6};
for (int i = 1; i < list.length; i++) {
list[i] = list[i - 1];
}
When i is 1, you assign list[1] = list[0], here list[0] value is 1
Then array is updated {1, 1, 3, 4, 5, 6}, loop again
When i is 2, you assign list[2] = list[1], here list[1] value is 1
Then array is updated {1, 1, 1, 4, 5, 6}, loop again
In that way, array is override {1, 1, 1, 1, 1, 1}