Re: but wait there's more!
"foolguy" <email@example.com> wrote:
>here u just call Cat's and animal's constructor,why the toString function
>will be called?
>u have not call the toString function...um this mean when u call a class,
>all functions of the class will automatically called? or i got wrong concept?
As far as I know, the only thing that happens when the class is created is
that a constructor is called. [In VB every class has a single "initialize"
method that runs every time the class is instantiated; in Java you have constructors--
and you can have several of these types of routines-- all with the same name,
just with different arguments. The constructor that is used depends on what
arguments you use when you create the new object: Class c = new Class(arguments
The ToString method would be called if you did something like this:
Java knows it can't print an object, so it looks for the ToString method
and does whatever it says.