Sport.add("Football") not adding?


#1

import java.util.*;

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

ArrayList<String> sports = new ArrayList<String>() ;
    sports.add("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);

I can't figure out why its not adding the new sport "Football" to the sports ArrayList. What am I missing? Any Help would be appreciated.


#2

Why do you say that it isn't being added?


#3

I've tried several times to add football to sports arraylist and it will not allow me to proceed in the lesson. I have quadruple checked my notes and other examples. I think that something very small is missing or that something is wrong with the lesson.

just for me to double check..

to add a new ArrayList called sports that keeps track of String types, I would write:

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

this allows me to move to step 2 in Lesson 13, where you must add "Football" to sports. For that I have been adding on the next line:

sports.add("Football");

Not working. I keep getting the red "X" that won't allow me to move to the next step to add "Boxing".

Any ideas?? I wanted to finish this a few days ago, but have tried so many different variations....still with no luck.


#4

I'm not getting any error message, which leads me to believe that I used the add method correctly, however I'm stumped


#5

Do you think it's being added or not? Your posts contradict each other.

If you're unsure about whether you added it, can you think of a way of finding out? Guessing doesn't do any good.
You won't be able to solve anything if you don't identify the problems first. So start there.