super 与 this 关键字

2017-10-10 09:37:00
admin
原创
524
public class SuperDemo {
    public static void main(String []args) {
        new SubClass().showMessage();
    }
}

class SubClass extends SuperClass {
    int i =100;
    public void showMessage() {
        System.out.printf("super.i = %d, this.i = %d\n", super.i, this.i);
    }
}

class SuperClass {
    int i = 50;
}
 
  • QQ讨论群
  • 关注微信
    • 欢迎咨询
    • 欢迎加入QQ群 16506021
  • 公众号:源宝网络