由于静态方法仅限于类,为什么子类在下面的代码中使用超类的静态方法?在子类中访问超类静态方法
public class StaticMethodEg extends Superclass {
public static void main(String args[]) {
System.out.println(StaticMethodEg.MyStaticMethod(2313123));
}
}
class Superclass {
public static int MyStaticMethod(int i) {
Integer value = new Integer(i);
return value + 1234;
}
}
输出
2314357
***扩展子类***亲爱的上帝为什么? –
对不起错误的程序...纠正它 –