I am using the below code. The first line is giving java.lang.NumberFormatException, and the second is giving java.lang.NullPointerException. I'm unable to figure out why.
int intValue =Integer.parseInt(null);
Double double1 = Double.parseDouble(null);
                Because thats how they are implemented,
int intValue =Integer.parseInt(null);
If we look the parseInt implementation, they are throwing NumberFormatException if the input string is null   

And Double double1 = Double.parseDouble(null);
In parseDouble(String s) method there is  another method call i.e FloatingDecimal.readJavaFormatString(s).doubleValue();
 In readJavaFormatString(s) method is where exactly NullPointerException is thrown

FloatingDecimal.readJavaFormatString(s) method

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With