[code=java]public class People
{
int index = 1;
}[/code][code=java]public class Man extends People
{
int index = 2;
}[/code][code=java]public class Test{
public static void main(String[] args)
{
People person = new Man();
System.out.println(p.index);
}
}[/code]知道打印出来是父类的值,但不知道java内存是怎么分配的。 |