When I execute the following code, NullPointerException
occurs:
public static Integer getProperty(String name, Integer defaultValue) {
String value = null;
try {
return (value != null) ? Integer.parseInt(value) : defaultValue;
} catch (NumberFormatException e) {
return defaultValue;
}
}
public static void main(String[] args) {
getProperty("unit", null);
}
Can somebody explain me why this is happening?