Java code
public class Son extends Father { String value = null;//2 public Son() { super(); //1 System.out.println("Son: " + value);//3 } public static void main(final String[] args) { new Son(); } } class Father { public Father() { if (this instanceof Son) { Son lower = (Son) this; lower.value = "test"; } } } class Father { public Father() { if (this instanceof Son) { Son lower = (Son) this; lower.value = "test"; } } }
Download
The result of this is null
Step 1 Set as test
Step 2 Set as null
Step 3 Print out null
If not String value = null ; Just String value; Download
Step 1 Set to test
Step 2 Do nothing, because there is already a value, no need to set it to the default null value
Step 3 Print out null
So there is a difference between not setting a value for a field and setting it to null.