13/13 What is wrong with this?


#1

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

RestaurantForEach.java:15: error: cannot find symbol
ArrayList sports = new ArrayList();
^
symbol: class ArrayList
location: class RestaurantForEach
RestaurantForEach.java:15: error: cannot find symbol
ArrayList sports = new ArrayList();
^
symbol: class ArrayList
location: class RestaurantForEach
2 errors

import java.util.*;

public class GeneralizationsD {
	public static void main(String[] args) {

		ArrayList<string> sports = new ArrayList<string>();
		ArrayList<string> sports = new ArrayList<string>();

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

		}
*/


	}
}

#2

Missing type declaration, perhaps?

ArrayList<string> sports = new ArrayList<string>();

#3

Aw what I'm sorry that's not the wright code

This one isn't wright

import java.util.*;

public class GeneralizationsD {
public static void main(String[] args) {

	ArrayList<string> sports = new ArrayList<string>();
	ArrayList<string> sports = new ArrayList<string>();

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

	}

*/

}

}


#4

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