- public static void main(String[] args) {
- // TODO Auto-generated method stub
- A b = new B();
- b.setA(7);
- System.out.println(b.getA());
- }
- }
- class A{
- private int a =9;
- public int getA() {
- System.out.println("A");
- return a;
-
- }
- public void setA(int a) {
- this.a = a;
- this.a = getA()-1;
- }
- }
- class B extends A{
-
- public int getA(){
- System.out.println("B");
- return super.getA()-1;
- }
-
- public void setA(int a) {
- super.setA(a);
- }
- }
复制代码 猜猜打印出来的顺序
|
|