Java 对象的内存分配过程中的步骤
2022-09-04 08:39:11
当类实例化以下对象时,内存中会发生什么情况?
public class SomeObject{
private String strSomeProperty;
public SomeObject(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public void setSomeProperty(String strSomeProperty){
this.strSomeProperty = strSomeProperty;
}
public String getSomeProperty(){
return this.strSomeProperty;
}
}
在课堂上 :SomeClass1
SomeObject so1 = new SomeObject("some property value");
在课堂上 :SomeClass2
SomeObject so2 = new SomeObject("another property value");
如何将内存分配给新实例化的对象及其属性?