In java the following code works:
double a = 15.5+0.5;
System.out.println(a);
This will print 16.0
.
So why does the following return a runtime error:
String a = "15.5+0.5";
Double b = Double.parseDouble(a);
System.out.println(b);
How can I get the second example to not give an error and behave like the first when converting the string to double and calculating a value?