why is there a compile time error for the following code
class Tester {
void
test(Object s) { System.out.println ("Object version"); }
void test(Tester s) { System.out.println ("Tester version"); }
void test(SubTester s) { System.out.println ("SubTester version"); }
// Not compilable any more if you uncomment the line
// since
String and Tester are siblings
void test(String s) { System.out.println ("String version"); }
public static void main (String args[]) {
Tester c = new Tester ();
// Ambiguous, the most specific one which fit will be call
c.test (null); // SubTester version
c.test (new Object()); // Object version
}
}
class SubTester extends Tester{
}