logo CodeStepByStep logo

arrayListMystery7

Write the output produced by the method below when passed each of the following lists:

public static void mystery(ArrayList<Integer> list) {
    for (int i = 0; i < list.size(); i++) {
        int element = list.get(i);
        list.remove(i);
        list.add(0, element + 1);
    }
    System.out.println(list);
}
[10, 20, 30]
[8, 2, 9, 7, 4]
[-1, 3, 28, 17, 9, 33]

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.