初学者提问
package asia;
class bbb
{
String capital;
public void bbb()
{
capital=new String("Beijing");
}
public String getCapital()
{
return capital;
}
}
class aaa extends bbb
{
bbb b=new bbb();
public String getCapital()
{
return b.capital;
}
public static void main(String args[])
{
aaa a=new aaa();
System.out.println(a.getCapital());
}
}
为什么输出结果是null