在现场实例化和在构造函数中实例化有什么区别?
2022-09-04 20:46:01
这样做有什么区别:
public class SomeClass {
SomeObject obj = new SomeObject();
//rest of the code
}
和这个
public class SomeClass {
SomeObject obj;
public SomeClass(){
obj = new SomeObject();
}
//rest of the code
}