Learn

Great work! What did we learn so far?

  • For Loops: used to repeatedly run a block of code
  • For Each Loops: a concise version of a for loop
  • ArrayList: stores a list of data
  • HashMap: stores keys and associated values like a dictionary

Instructions

1.

Inside of the main method and before the for each loop, create an ArrayList called sports that stores String types.

2.

Add "Football" to sports.

3.

Now add "Boxing" to sports.

4.

The first for each loop in the code editor is missing the code that should be run. Inside of the for each loop, type:

System.out.println(sport);
5.

Uncomment the incomplete for each loop towards the bottom and complete the loop by typing:

for ( String city : majorCities.keySet() ) { }

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?