The foo() method is an example of overloading a method. With overloading, it is actually dependant on the reference used to call the method. Using a Son reference, the foo() method that takes a single string does match better than the var-arg version. Using a Dad reference, only the var-arg version is available.

You are seeing the magic of compile time vs. runtime processing. Apparently varg lists are enumerated and 'boxed' at compile time instead of performing it at runtime.

So once the compiler gets a hold of the class, the classfile pseudocode would look something like this:

Jose Campana
Ranch Hand

Joined: May 28, 2007
Posts: 339

posted Mar 25, 2008 17:57:00

0

Hello Guys!

My doubt has been cleared now. I feel like a fool now to be honest. I couldn't see it was an overload. and that was the end of the story. It's kinda pathetic because I've been studying for quite a long time now.

Thank you Henry ! you always pinpoint me to the root of the problem. And thanks to you guys(the other posters) as well.