Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Getting There Object Inheritance

mohamadreza azadi
mohamadreza azadi
5,167 Points

I need really help

this subject override toString() method right?? and Craig don't call the toString method but we see in video output has a toString method and he wont call the toString method

i'm so confused and lost i need really help

1 Answer

james south
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,258 Points

the toString method can be called implicitly by printing the object. in the video you see Craig compile and run example.java. at 8:03 in the previous video, we get a glimpse of example.java, and see that in main Craig instantiates a treet object, then prints a statement and fills in the treet object with the string formatter. the result is not really intelligible; this is what Craig fixes in the following video that you are asking about. by overriding the default toString method, he gets a more useful string representation of the object when example.java is run and the object is printed.