您的位置:首页 > 其它

调用静态方法是不能用this关键字的。直接使用类名就可以了

2011-05-02 23:21 716 查看
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
say();
Test.say();
//Cannot use this in a static context
//如果写成this.say(), 是错误的,
}

public static void say(){
System.out.println("大家好");
}
}


调用静态方法是不能用this关键字的。直接使用类名就可以了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐