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 Object Inheritance

pawkan kenluecha
pawkan kenluecha
26,303 Points

Why does the code toString run automatically ?

Here, To lessen my confuse over this course. I still don't understand. Why this toString method can call by default without make a call. As per my understanding , normally we have to call method first before they're working.

For example, we printf object "tweet" directly not "tweet.toString()". But from this exercise, It's same as we print out with "tweet.toString()".

1 Answer

iftekhar uddin
iftekhar uddin
4,194 Points

http://programmedlessons.org/java5/Notes/chap27/ch27_10.html

This is a pretty good explanation. The print function automatically uses it's toString method.