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

Java Java Data Structures Exploring the Java Collection Framework Sets

5 Answers

Balazs Peak
Balazs Peak
46,160 Points

First I realized that the "Blog" class constructor wants a list, but you are giving it several other parameters instead :)

After that, I checked the actual code challenge description. Basically, you should create a "getAllAuthors" method in the "Blog" class, which handles "BlogPost" objects. But you, instead, tried to do this the other way around. You tried to put it into the "BlogPost" class, and tried to handle "Blog" objects.

I hope this helps. If you still struggle, feel free to ask further questions. If I might not notice, contact me here: http://facebook.com/puklibalazs

Chris Needham
Chris Needham
1,871 Points

Yeah. Must have been sleepy. Got something backwards.

Chris Needham
Chris Needham
1,871 Points

Why is this answer wrong? public Set getAllAuthors() { Set<String> authors = new TreeSet<String>(); for(BlogPost post : mPosts ) { authors.add(post.getAuthor()); } return authors; }

Error says: " Bummer! You should be using a Generic type, specifically Set<String>. You returned a java.util.Set"

Instruction says.. returns a java.util.Set

Balazs Peak
Balazs Peak
46,160 Points

You can not return a "Set", you have to return a "Set of something" only :D the method declaration will start like this:

public Set<String> getAllAuthors() {......etc