What is the output of the following code? 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]; for (int i = 0; i < list.length; i++) System.out.print(list[i] + " "); } }
You copy the first location to the second, and then the second to the third, and so on. Effectively the value of the first location (1) is copied to all locations.