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 Getting There Override an inherited method

Sonam Klein
Sonam Klein
858 Points

Not sure what im supposed to do here

Hey I'm a bit lost on exactly what im supposed to do for this exercise. Would someone mind posting the answer and/or explaining it. Thanks

1 Answer

Kourosh Raeen
Kourosh Raeen
23,733 Points

You need to add a public method, named toString(), to the class that returns a String. Use the annotation @Override above the method definition. Inside the method you only have a return statement that returns the desired string. To create the string use concatenation with the + symbol and use mTitle and mAuthor to add their values at appropriate places in the string.

Sonam Klein
Sonam Klein
858 Points

Good explanation, thanks for the help!