-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
8
ADDITIONAL SYSTEM INFORMATION :
HP Laptop / Windows 10 64bits / jdk 1.8.0_131
A DESCRIPTION OF THE PROBLEM :
When I am trying to use Double.parseDouble(String s), It does not work perfectly as per Java Documentation.
Example :
Double.parseDouble("String") - NumberFormatException
Double.parseDouble(null) - NullPointerException
Double.parseDouble("NaN") - Suppose to get "NumberFormatException" but i am getting "NaN".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Double.parseDouble("NaN"), You will get NaN insteed of NumberFormatException.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect result is NumberFormatException but I am getting NaN.
ACTUAL -
NaN is an actual result.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
System.out.println(Double.parseDouble("2020")); // OutPut - 2020.0
System.out.println(Double.parseDouble("String")); // OutPut - java.lang.NumberFormatException: For input string: "String"
System.out.println(Double.parseDouble("NaN")); // OutPut - NaN
System.out.println(Double.parseDouble(null)); // OutPut - java.lang.NullPointerException
}
}
---------- END SOURCE ----------
FREQUENCY : always
HP Laptop / Windows 10 64bits / jdk 1.8.0_131
A DESCRIPTION OF THE PROBLEM :
When I am trying to use Double.parseDouble(String s), It does not work perfectly as per Java Documentation.
Example :
Double.parseDouble("String") - NumberFormatException
Double.parseDouble(null) - NullPointerException
Double.parseDouble("NaN") - Suppose to get "NumberFormatException" but i am getting "NaN".
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Double.parseDouble("NaN"), You will get NaN insteed of NumberFormatException.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Expect result is NumberFormatException but I am getting NaN.
ACTUAL -
NaN is an actual result.
---------- BEGIN SOURCE ----------
public class Test {
public static void main(String[] args) {
System.out.println(Double.parseDouble("2020")); // OutPut - 2020.0
System.out.println(Double.parseDouble("String")); // OutPut - java.lang.NumberFormatException: For input string: "String"
System.out.println(Double.parseDouble("NaN")); // OutPut - NaN
System.out.println(Double.parseDouble(null)); // OutPut - java.lang.NullPointerException
}
}
---------- END SOURCE ----------
FREQUENCY : always