Originally posted by chen qing:
Class Object is the root of the class hierarchy. Every class,including String,has Object as a superclass.
Suraj Berwal
Sun Certified Programmer for Java 2 Platform
Originally posted by Maulin, Vasavada:
oops!
m so sorry. it should be method "f()" not "m()". really sorry for so many mistakes.
maulin.
Originally posted by wei liu:
thanks Maulin!
in my code , there is no class relationship such as a & b which appear in your code.well, i m still confused about it.is there anyone who has other explanations?
Originally posted by serendipity:
I have a test as following:
class a {}
class b extends a {}
public class Test {
void f(a a1) {
System.out.println("a1");
}
void f(b b1) {
System.out.println("b1");
}
static void main(String[] s) {
Test t = new Test();
t.f(null);
}
}
This is the previous example and the result is : b1
I modify this example like the following:
class a {}
class b extends a {}
class c {}
public class Test {
void f(a a1) {
System.out.println("a1");
}
void f(b b1) {
System.out.println("b1");
}
void f(c c1) {
System.out.println("c1");
}
static void main(String[] s) {
Test t = new Test();
t.f(null);
}
}
And when run this example, compiler error generated:
"reference to f is ambiguous, both method f(b) in Test and method f(c) in Test match."