我有一个SomeClass
具有以下成员字段和构造函数的类
private int someInt;
private String someStr;
private String strTwo;
//the contructors
public SomeClass() {}
// second constructor
public SomeClass(int someInt, String someStr) {
this.someInt = someInt;
this.someStr = someStr;
}
// my emphasis here
public SomeClass(int someInt, String someStr, String strTwo) {
// can i do this
new SomeClass(someInt, someStr); // that is, calling the former constructor
this.strTwo = strTwo;
}
第三个构造函数是否会创建与以下相同的对象:
public SomeClass(int someInt, String someStr, String strTwo) {
this.someInt = someInt;
this.someStr = someStr;
this.strTwo = strTwo;
}