Java中静态方法(上下文)的使用

   例子:

package com.smart.lesson_two;

public class Test {
    static void method(){
        System.out.println("---------");
    }
}

class Son extends Test{
    public static void method(){
        System.out.println("------");
        super.method();   //错误   静态方法中不能够直接调用非静态变量;super、this分别是父类对象与子类对象
    }
}

 

posted on 2018-11-29 10:21  溪水静幽  阅读(456)  评论(0)    收藏  举报