1.
Q4: What are the contents of
alpha
after this code has been executed?
import java.util.ArrayList;
ArrayList<Integer> alpha = new ArrayList<>();
Collections.addAll(alpha, 10, 20, 30, 40, 50, 60, 70);
int start = alpha.get(alpha.size() - 1);
for (int i = 1; i < alpha.size(); i++) {
alpha.set(i, alpha.get(i - 1));
}
alpha.set(0, start);
- {20, 30, 40, 50, 60, 70, 10}
- {10, 20, 30, 40, 50, 60, 70}
- {10, 10, 20, 30, 40, 50, 60}
- {70, 10, 10, 10, 10, 10, 10}
- {10, 10, 10, 10, 10, 10, 10}