Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

We have written the following StarWars Movies class below, and we want to be able to iterate over the movies using a for-each loop. However,

image text in transcribed

We have written the following StarWars Movies class below, and we want to be able to iterate over the movies using a for-each loop. However, our code doesn't work, and we have no idea why. TASK: Fix the bug(s) in our code. EXAMPLE: After running the following lines of code: StarWarsMovies movies = new StarWarsMovies(): for(String m: movies) { System.out.println(m): We will print the following: A New Hope The Empire Strikes Back Return of the Jedi The Phantom Menace Attack of the Clones Revenge of the Sith The Force Awakens The Last Jedi The Rise of Skywalker HINT: We asked a tutor for help by submitting a ticket to the lab queue, and the tutor suggested we look into how to properly implement the Iterable interface. Tutors are so helpful and kind Write a program, test using stdin stdout Time limit: 8 seconds Memory limit: 256 MB 1 class Star WarsMovies { final private ArrayList movies; public Star Wars Movies() { this.movies = new ArrayList(); this.movies.add("A New Hope"); this.movies.add("The Empire Strikes Back"); this.movies.add("Return of the Jedi"); this.movies.add("The Phantom Menace"); this.movies.add("Attack of the Clones"); this.movies.add("Revenge of the Sith"); this.movies.add("The Force Awakens"); this.movies.add("The Last Jedi"); this.movies.add("The Rise of Skywalker")

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

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

What is meant by the term service recovery?

Answered: 1 week ago

Question

5. Understand how cultural values influence conflict behavior.

Answered: 1 week ago

Question

8. Explain the relationship between communication and context.

Answered: 1 week ago