Big bug, "get code" offer gives wrong code

I have just write right code, but this error message appear… (1° porblem)

when i try to ‘GET CODE’, happens this ! (2° problem)

see the screen…

Why? help me !

1 Like

i have the same bug. Then i cannot finish the course

i hope someone can help us, or the admin fix the bug…

Try this code

import java.util.*;

public class GeneralizationsD {
public static void main(String args) {
ArrayList sports = new
ArrayList();
sports.add(“Football”);
sports.add(“Boxing”);

	for(String sport : sports) {
		System.out.println(sport);
	}

	//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 ( String city : majorCities.keySet()) {

		System.out.println(city + " was founded in " + majorCities.get(city));

	}



}

}

You are missing the new when you create your new array.

2 Likes

in your code you dont declare the type of the Array on line 5
I finished the course.
My Code is :
import java.util.*;

public class GeneralizationsD {
public static void main(String args) {
ArrayList sports = new ArrayList();
sports.add(“Football”);
sports.add(“Boxing”);

	for(String sport : sports) {

System.out.println(sport);
}

	//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 (String city : majorCities.keySet()) {

		System.out.println(city + " was founded in " + majorCities.get(city));

	}



}

}

This doesn’t work because the request is an ArrayList of strings…

i have declared the type between the diamonds!
ArrayList < String > sports = new ArrayList < String >() ;

your code doesn’t work …

thank you! :slight_smile:

But the bug of 'get code’ is still here!

1 Like

Yes, that’s not good :smile: You should use the Report a Bug tool in the exercise for that.

1 Like

I have finished the course and it is working well. I written this code and it worked:

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

You should pay attention to the spaces between symbols. For example I had a space between "> ( " and I got error.

I hope this help you.

1 Like

This is my code smile:

thank you @mitko321 and @travelvox.

But no one answer to my bug, and i’ve already report to codeacademy.

Why? Bus is not resolved…!

Isn’t working for me either. I have exactly what you have in your screenshot and when I used get code it’s exactly what I put.

See the answer of @travelvox for the solution.

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