Big bug, "get code" offer gives wrong code


#1

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 !


#2

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


#3

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


#4

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

	}



}

}


#5

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


#6

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

	}



}

}


#7

This doesn't work because the request is an ArrayList of strings..


#8

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

your code doesn't work ..


#9

thank you! :smile:

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


#10

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


#11

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.


#12

This is my code smile:


#13

thank you @mitko321 and @travelvox.

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


#15

Why? Bus is not resolved..!


#16

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.


#17

See the answer of @travelvox for the solution.


#18

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