public class Constructor1 {
private String str = "nihao";
private String str1 = null;
private String str2 = str1;
Constructor1(String s){
this.str1
创建一个类,它包含一个在定义时就被初始化了的String域,以及另一个通过构造器初始化的域
![](https://img-home.csdnimg.cn/images/20240711042549.png)
public class Constructor1 {
private String str = "nihao";
private String str1 = null;
private String str2 = str1;
Constructor1(String s){
this.str1