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 trialRajeev Mohan
Courses Plus Student 281 PointsConfusion regarding toString()
I read in the forum as said by Evgeny Chulak "If you haven't overridden the toString() method, something still happens but it will not necessarily perform what you want."
Is this the reason that we are getting "com.teamtreehouse.Treet@511d50c0" as output in the "Class Review" video, because we have not overridden the toString() method?
2 Answers
Simon Coates
28,694 PointsIf you don't override it, a class gets the definition that comes with the object class (or the nearest ancestor that defines a toString method). The string you're getting is probably consistent with the object class toString method. see https://docs.oracle.com/javase/7/docs/api/java/lang/Object.html#toString() .
Trevor Bye
4,474 Pointshttp://www.geeksforgeeks.org/overriding-tostring-method-in-java/
Here is an alternative explanation.