Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialPatrick Hofer
1,398 PointsWhat is wrong with this HashMap?
Hello, I stuck. I really don't no what's wrong with my code. Compiler error. But where?
import android.os.Bundle;
import android.widget.SimpleAdapter;
public class WebsiteListActivity extends ListActivity {
public static final String KEY_NAME = "name";
public static final String KEY_URL = "url";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_website_list);
String[] keys = { KEY_NAME, KEY_URL };
int[] ids = { android.R.id.text1, android.R.id.text2 };
HashMap<String, String> site1 = new Hashmap<String,String>();
site1.put(KEY_NAME,"YT");
site1.put(KEY_URL,"youtube.com");
HashMap<String, String> site2 = new Hashmap<String,String>();
site2.put(KEY_NAME,"FB");
site2.put(KEY_URL,"facbook.com");
}
}
2 Answers
Marc-Oliver Gern
8,747 PointsHi Patrick, check your spelling. "Hashmap" βΒ it's "HashMap" with capital M
Aaron Arkie
5,345 PointsHello! Marc-Oliver Gern is correct
HashMap<String, String> site1 = new Hashmap<String,String>(); //capitalize the M in map after new Hash(M)ap.
site1.put(KEY_NAME,"YT");
site1.put(KEY_URL,"youtube.com");
Patrick Hofer
1,398 PointsPatrick Hofer
1,398 PointsThanks Marc!