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 Maps

Rashadat Mirzayev
Rashadat Mirzayev
14,601 Points

I do not get the method

in this line: List<Treet> authoredTreets = treetsByAuthor.get(treet.getAuthor());

getAuthor() only get the author not the treet, wright? it suppose to put author of the treet to authoredTreets?

2 Answers

Omar Amin
PLUS
Omar Amin
Courses Plus Student 1,194 Points

The first getAuthor() method returns the author of the treet. The second get method which is invoked by the treetsByAuthor map returns the value associated with the key (in this case the returned author). This returned value (which is the treet) will be put in the authoredTreets list. It might be null if the author is not in the treetsByAuthor map. I hope you got it.