|
使用法则 1.在静态方法中,用类名调用此方法外部的变量或方法,只能调用静态的,不能直接用类名调用非静态的 2.在静态方法中,调用非静态方法和变量,要用其对象实例引用 3.在静态方法中不能用this.,this为非静态变量
关于继承与覆盖 Like an instance method, a static method can be inherited. However, a static method cannot be overridden. If a static method defined in the superclass is redfined in a subclass, the method defined in the superclass is hidden. 静态方法可以被继承不能被覆盖,如果一个父类中被定义过的静态方法,在子类中重新被定义,父类中的会被隐藏
|
一共有 1 条评论