hello all,
i cannot manage to understand how
java chooses the most specific methods
class Tester {
void
test(Object s) { System.out.println ("Object version"); }
void test(
String s) { System.out.println ("String version"); }
public static void main (String args[]) {
Tester c = new Tester ();
c.test (null); // SubTester version
//c.test (new Object()); // Object version
}
}
i read this from some links on the net
In general terms, if the parameters of Method A are valid in Method B, but not vice versa, Method B is said to be "more specific" than Method A.
in this case, what is method A and B?
how does things works in this case?
String extends Object, so if i pass a String parameter will be valid for both of methods
If i pass an Object, parameters will be valid only for the Object method
anyone could clarify?
thanks in advance and regards
marco