A是父類,B是繼承A的子類。B中我這樣定義的public class B extends A { public String name ; public B(String name){ this.name = name; }然后我在測試程序中:A test = new B(“托爾斯泰”);System.out.println(test.name);最后得到的這個值是null。我想知道為什么我會得不到我的賦值呢?
主程序中調用繼承的子類變量值時得不到數值呢?
baobao9888
2015-12-04 10:57:33