日期:2014-05-20 浏览次数:20789 次
class Test1{ private int i = 0; Test1(int i){ this.i = i; } public int value(){return i;} public void readi(){System.out.println(Integer.toString(i));} } public class Test extends Test1{ Test(){ super(10); } public int value(){return super.value()*10;} public static void main(String[] args){ Test test = new Test(); test.value(); test.readi(); } }
//注意代码格式 class Test1 { private int i = 0; Test1(int i) { this.i = i; } public int value() { return this.i; } public void readi() { System.out.println(Integer.toString(this.i)); } } public class Test extends Test1 { Test() { super(10); } public int value() { return super.value() * 10; } public static void main(String[] args) { Test test = new Test(); System.out.println(test.value()); //看看这行输出多少 test.readi(); //i 当然等于 10,因为你 super(10); 了 } }