Question: How to read this code? can anyone explain. I don't know why I got wrong answer Language/Type: Java ArrayList Collections mystery Marty Stepp (on 2016/09/08)

How to read this code? can anyone explain. I don't know why I got wrong answer

How to read this code? can anyone explain. I don't know why

Language/Type: Java ArrayList Collections mystery Marty Stepp (on 2016/09/08) Author: Consider the following method public static void mystery2 (ArrayList list) for (int = list . size() - 1; i >= 0; i-) { if(i % 2 0) { list.add(list.get(i)); } else list.add(0, list.get(i)); System.out.println(list); Write the output produced by the method when passed each of the following ArrayLists [10, 20, 30] [8, 2, 9, 7, 4] [-1, 3, 28, 17, 9, 33] [18, 28, 30, 30, 28, 101 Sound FIX [9, 7, 8, 2, 9, 7, 4, 4, 2, 8] Submit You passed 0 of 3 tests. Try again. question #1: [10, 20, 30] your answer: [10, 20, 30, 30, 20, 10] result: fail question #2: [8, 2, 9, 7, 4] your answer: [9, 7, 8, 2, 9, 7, 4, 4, 2, 8] result: fail

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!