鉴于这对故意非常简单的类
class Base {
private int a;
private int b;
public Base() {
this.a = 0;
this.b = 0
}
}
class Derived extends Base {
private int c;
Derived() {
super();
this.c = 0;
}
我的理解是,做Derived d = new Derived();
至少可以保证这一点a
并且b
是连续分配的。但是,子对象是否可以与内存中Base
的剩余对象分开,或者整个对象是否必须连续分配。c
Derived
另外,我的假设是否正确,两个int
s inBase
是连续的?
即使它是连续分配的,子对象是否可以在离开伊甸园空间时Base
与其他对象分开?Derived