相关疑难解决方法(0)

为什么Java不允许覆盖静态方法?

为什么不能覆盖静态方法?

如果可能,请举例说明.

java static static-methods overriding

519
推荐指数
14
解决办法
26万
查看次数

从静态方法调用超级方法

是否可以从子静态方法调用超静态方法?

我的意思是,以通用的方式,到目前为止,我有以下内容:

public class BaseController extends Controller {
    static void init() {
        //init stuff
    }
}

public class ChildController extends BaseController {
    static void init() {
        BaseController.loadState();
        // more init stuff
    }

}
Run Code Online (Sandbox Code Playgroud)

并且它有效,但我想以通用方式执行它,比如调用super.loadState(),这似乎不起作用......

java inheritance static super

23
推荐指数
2
解决办法
3万
查看次数

标签 统计

java ×2

static ×2

inheritance ×1

overriding ×1

static-methods ×1

super ×1