Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Management Systems

Authors: Patricia Ward, George A Dafoulas

1st Edition

1844804526, 978-1844804528

More Books

Students also viewed these Databases questions

Question

Define sampling, sample population, and sample size.

Answered: 1 week ago