13/13 adding keys to ArrayList


#1

Hi, I'm stuck at this exercise, code seems abt right to me, will someone identify the mistake, thank you!

https://www.codecademy.com/en/courses/learn-java/lessons/data-structures/exercises/generalizations-data-structures


What did I do wrong adding "Football" to the sports object?


import java.util.*;

public class GeneralizationsD {
	public static void main(String[] args) {
    
    ArrayList<String> sports = new ArrayList<String> ();
    
        sports.add("Football");
        sports.add("Boxing");


		for(String sport : sports) {

		}

		//Major cities and the year they were founded
		HashMap<String, Integer> majorCities = new HashMap<String, Integer>();

		majorCities.put("New York", 1624);
		majorCities.put("London", 43);
		majorCities.put("Mexico City", 1521);
		majorCities.put("Sao Paulo", 1554);

/*
		for () {

			System.out.println(city + " was founded in " + majorCities.get(city));

		}
*/


	}
}

Thank you very much!


#2

Try just deleting the space between ArrayList and ();

I realize you shouldn't have to, but this worked for me.

import java.util.*;

public class GeneralizationsD {
	public static void main(String[] args) {
    ArrayList<String> sports = new ArrayList<String>();

    sports.add("Football");
    sports.add("Boxing");
    
		for(String sport : sports) {
			System.out.println(sport);
		}

		//Major cities and the year they were founded
		HashMap<String, Integer> majorCities = new HashMap<String, Integer>();

		majorCities.put("New York", 1624);
		majorCities.put("London", 43);
		majorCities.put("Mexico City", 1521);
		majorCities.put("Sao Paulo", 1554);

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

			System.out.println(city + " was founded in " + majorCities.get(city));

		}


	}
}

#3

Its resolved! Thanks!