Here is an example showing the difference:
import java.util.*; public class Test { public static void main(String[] args) { Properties defaults = new Properties(); defaults.setProperty("x", "x-default"); Properties withDefaults = new Properties(defaults); withDefaults.setProperty("x", "x-new"); withDefaults.remove("x");
In the first case, we add a new value that is different from the default value for the "x" property, and then delete it; when we request "x", the implementation will see that it is missing, and consult the default settings instead.
In the second case, we copy the default values ββto the property without indicating that they are by default - they are simply property values. Then we replace the value "x" and then delete it. When the implementation as the request "x" sees that it is not present, but it has no default recommendations, therefore the return value is null.
source share