ITeye博客

Super和this

maybe723 · 2008-05-06 10:39 · CoreJava · Markdown

Super的使用:对于构造函数,必须是构造函数的第一行,即为super(),super(10)等,在其他的非静态方法中,super.i,super.method();

This的使用:对于构造函数,必须是构造函数的第一行,即为this(),this(10)等, 在其他的非静态方法中,this.i,this.method();

在静态方法中不能使用this和super, 它只能在实例方法、函数闭包和全局代码中使用, 不能在静态成员的内部使用 this 关键字,因为 this 可能没有上下文。

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。