????* ????????????????????????????????д????????????Ч????
?????????????????????????д????????????????? *
?????????????????????
????????????????????A?????????????????????????????????
publicclassA{
publicvoidunstaticMethod(){
System.out.println("SuperClassunstaticMethod");
}
publicstaticvoidstaticMethod(){
System.out.println("SuperClassstaticMethod");
}
}
???????????????????????B???????????????????????????????(???????????д?????????)??
public class B extends A {
public void unstaticMethod() {
System.out.println("SunClass unstaticMethod");
}
public static void staticMethod() {
System.out.println("SunClass staticMethod");
}
}
???????????????????в????
public class Test {
@SuppressWarnings("static-access")
public static void main(String[] args) {
A a = new A();
A a2 = new B();
a.unstaticMethod();
a2.unstaticMethod();
a.staticMethod();
a2.staticMethod();
}
}
???????н????
SuperClass unstaticMethod
SunClass unstaticMethod
SuperClass staticMethod
SuperClass staticMethod
?????????н??????????????????????????????????????Ч????????????????С?