Re: question about the toString Method



Anytime something in Java receives an object and wants a String, it
calls the objects toString() method.

toString() is defined for the Object class; the base class of all
classes in Java.

On Dec 27, 12:46 pm, "Art Cummings" <aikia...@xxxxxxxxx> wrote:
Hello everyone,

I've been trying to understand how the toString Method works.  I've been
looking at this during the semester break so the instructor hasn't been
available for questions.  Specifically i'm trying to understand why the
System.out.println method calls the toString method in my Course class.
I've included the bare minimum, that I think is necessary to understand the
question i'm asking.  I omitted the Textbook and Instructor classes.  What's
confusing me is why there seems to be nothing in the calling statement to
direct the flow of the program to the toString method in the Course class.

thanks to anyone that can shed some light

Art

.


Quantcast