13. Generalizations


#1



https://www.codecademy.com/courses/learn-java/lessons/data-structures/exercises/generalizations-data-structures?action=lesson_resume&link_content_target=interstitial_lesson


I don't understand how to start the expression
for(String sport : sports) System.out.println(sport):wink: {

	GeneralizationsD.java:13: error: illegal start of expression
	for(String sport : sports) System.out.println(sport);) {
	                                                     ^

1 error
^
1 error


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 () {

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

		}
*/


	}
}


#2

Hello

There is an extra open bracket -

Delete the bracket after the ; .
Run the code again.

Let me know if it works.


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.