The Integer.getInteger(String)
method states the following:
The first argument is treated as the name of a system property. System properties are accessible through the
System.getProperty(java.lang.String)
method. The string value of this property is then interpreted as an integer value using the grammar supported by decode and an Integer object representing this value is returned.If there is no property with the specified name, if the specified name is empty or null, or if the property does not have the correct numeric format, then null is returned.
The other method, with two parameters, has a default value that is returned instead of null, if the parameter is not set or is an invalid integer.
Since sun.arch.data.model
is a valid property with a numeric value, its value is returned both times (it is 32). com.samples.data.model
is either non-existent or non-numeric and so the invalid handling logic is invoked instead, returning the default of 5 when specified, and null
in the second call, where the default isn’t specified.
3
solved Use of Integer.getInteger() [duplicate]