Problem adding Arraylist java


#1

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

Hello !
I need to add a Arraylist with the name sports but after compiling the console shows up two errors I can’t identify. Can somebody help me correct this code?

the errors are :

GeneralizationsD.java:7: error: cannot find symbol
Arraylist sports = new Arraylist();
^
symbol: class Arraylist
location: class GeneralizationsD
GeneralizationsD.java:7: error: cannot find symbol
Arraylist sports = new Arraylist();
^
symbol: class Arraylist
location: class GeneralizationsD
2 errors

my code is:



import java.util.*;

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


	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

Error:

cannot find symbol

This line of code

Arraylist<String> sports = new Arraylist<String>();

should be

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


#3

you didn’t specify what data type the new ArrayList was,

Arraylist sports = new Arraylist();

should be

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

you also might be getting errors because you typed Arraylist instead of ArrayList


#5

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