例题如下:
class A {
public static void doSth(){
System.out.println("Doing something in A");
}
}
class B extends A {
public static void doSth(){
System.out.println("Doing something in B");
}
}
class C extends B {
public static void doSth(){
System.out.println("Doing something in C");
}
}
class test {
public static void main(String [] args) {
A.doSth();
B.doSth();
C.doSth();
A aInstance = new B();
B bInstance = new C();
C cInstance = new C();
aInstance.doSth();
bInstance.doSth();
cInstance.doSth();
}
}
执行结果是
Doing something in A
Doing something in B
Doing something in C
Doing something in A
Doing something in B
Doing something in C
前三个我可以理解,后三个我就不懂了,static在这里是起什么样的作用呢?
跪求高手解惑,感谢...