Re: question about the toString Method
- From: Roedy Green <see_website@xxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 27 Dec 2007 23:40:48 GMT
On Thu, 27 Dec 2007 12:46:52 -0500, "Art Cummings"
<aikiart7@xxxxxxxxx> wrote, quoted or indirectly quoted someone who
said :
System.out.println(myCourse); **************WHY DOES THIS CALL THE
toString method in the Class course?****************
Have a look at how println is implemented. Look in src.zip.
In essence it looks something like this
void println ( Object o )
{
// the console needs a string of chars. I just have an object
// so I will call the the toString method which every object has
// or overrides.
sendToConsole ( o.toString() );
println();
}
Why? How else would you get a String to print?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
.
- References:
- question about the toString Method
- From: Art Cummings
- question about the toString Method
- Prev by Date: Re: How To retrieve the full user name, in Vista??
- Next by Date: Re: Copy files in java gives me out of memory error
- Previous by thread: Re: question about the toString Method
- Next by thread: Re: question about the toString Method
- Index(es):