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

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???

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

Thanks a lot. It works… :slight_smile:

1 Like