The method with the most concrete subclass is selected. String is a subclass of Object, and null can be cast to any class, so the String method is selected.
Serg Masow
Ranch Hand
Joined: Dec 17, 2007
Posts: 45
posted
0
the compiler always choose the most specific method, which will be invoked. This blog linkdecribes very well the choose of the "most specific method"
SCJP 6.0 [95%]
Gosia Wittemann
Ranch Hand
Joined: Nov 02, 2007
Posts: 50
posted
0
Thanks for your answers. Of course, I should have thought of it.
I tried it with a method with a StringBuffer type parameter and you get a:
Exception in thread "main" java.lang.Error: Unresolved compilation problem: The method test(Object) is ambiguous for the type A
as expected.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.