GeneralizationsD.java:7: error: cannot find symbol sports.put("Football");


#1
import java.util.*;

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

		ArrayList<String> sports = new ArrayList<String>();
    sports.put("Football");


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

		}
*/


	}
}

WHATS WRONG HERE???


#2

Did you mean to use .add here? It looks like add() is for lists and put() is for HashMaps.


#3

Thanks a lot. It works... :smile: