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 trial

Android Build a Blog Reader Android App Exploring the Master-Detail Template Exploring the Master-Detail Template

Exploring the Master-Detail Template

add 2 more Dummy items to this list, with 2 more movie titles.Make sure to give them IDs of "4"and"5" to follow the pattern i put what i thought was the correct answer but it was rejected please help me.

DummyContent.java
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DummyContent {

    public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
    public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();

    static {
       addItem(new DummyItem("1", "The Avengers"));
       addItem(new DummyItem("2", "The Hobbit"));
        addItem(new DummyItem("3", "Ball of Fire"));
        addItem(new DummyItem("1", "Item 1"));
        addItem(new DummyItem("2", "Item 2"));
        addItem(new DummyItem("3", "Item 3"));
        addItem(new DummyItem("4", "Holy Wars"));
        addItem(new DummyItem("5", "More than Conquerors"));

    }

    private static void addItem(DummyItem item) {
        ITEMS.add(item);
        ITEM_MAP.put(item.id, item);
    }

    /**
     * A dummy item representing a piece of content.
     */
    public static class DummyItem {
        public String id;
        public String content;

        public DummyItem(String id, String content) {
            this.id = id;
            this.content = content;
        }
    }
}

2 Answers

Hie. Your code for adding the two movie titles looks fine to me. Earlier on helping a friend who had the same problem , i asked him to remove the code for Item1 , Item 2 and Item 3. I think you were supposed to replace those when you did the first task challenge. So i suggest you try removing the code for adding Item1,2 and 3 and check work. Please notify me whether it worked for you too or not.

this should pass the whole chalenge... Task 1 & 2

import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map;

public class DummyContent {

public static List<DummyItem> ITEMS = new ArrayList<DummyItem>();
public static Map<String, DummyItem> ITEM_MAP = new HashMap<String, DummyItem>();

static {
   addItem(new DummyItem("1", "The Avengers"));
   addItem(new DummyItem("2", "The Hobbit"));
    addItem(new DummyItem("3", "Ball of Fire"));
    addItem(new DummyItem("4", "Holy Wars"));
    addItem(new DummyItem("5", "More than Conquerors"));

}

private static void addItem(DummyItem item) {
    ITEMS.add(item);
    ITEM_MAP.put(item.id, item);
}

/**
 * A dummy item representing a piece of content.
 */
public static class DummyItem {
    public String id;
    public String content;

    public DummyItem(String id, String content) {
        this.id = id;
        this.content = content;
    }
}

}