13/13-4


#1



https://www.codecademy.com/courses/learn-java/lessons/data-structures/exercises/generalizations-data-structures
i have no idea where to type the for each loop "System.out.println(sport);"


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 sports : 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));

		}
*/


	}
}


#2

instruction:

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

this is the first for each loop

for(String sports : sports) {
		
      
      
	}

inside this you have to wrire

System.out.println(sport);

but see in your code you added a ; after for each loop that is wrong here

	for(String sports : sports);  //remove it

#3

[quote="wilsoa07132, post:1, topic:58350"]
ArrayList<String> sports = new ArrayList<String>();
sports.add("Football");
sports.add("Boxing");

	for(String sport : sports); {
	
  System.out.println(sport);      
	}

you have to remove sports and make (sport:sports)


#4

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