目标类
public class ConstructTest { private String notInitStr; private String initStr; public ConstructTest(String initStr){ this.initStr = initStr; } public String getNotInitStr() { return notInitStr; } public void setNotInitStr(String notInitStr) { this.notInitStr = notInitStr; } public String getInitStr() { return initStr; } public void setInitStr(String initStr) { this.initStr = initStr; }}
测试代码:
ConstructTest ct = new ConstructTest("string inited!");System.out.println(ct.getInitStr());System.out.println(ct.getNotInitStr());
测试结果:
string inited!null