Reputation: 13041
I cant figure it out
double d = Double.valueOf(str);
double d2 = Double.parseDouble(str);
both methods produce the following exception:
java.lang.NumberFormatException: Invalid double: "-73.04"
However, the following hardcoded value works just fine:
double d = Double.valueOf("-73.04");
Upvotes: 0
Views: 181
Reputation: 178343
After copying the number from the title of this question and pasting into IntelliJ between double-quotes, it became clear what the problem is:
double d = Double.parseDouble("\u200E-73.04");
Exception in thread "main" java.lang.NumberFormatException: For input string: "?-73.04"
Copying it from your hard-coded -73.04
does not have this behavior.
You have a "left-to-right mark" Unicode character in your string somehow. You must eliminate that extraneous Unicode character from your string before parsing it.
Upvotes: 2