I need to convert Object o to Double. Is the correct way to convert it to String first?
解决方案
You can't cast an object to a Double if the object is not a Double.
Check out the API.
particularly note
valueOf(double d);
and
valueOf(String s);
Those methods give you a way of getting a Double instance from a String or double primitive. (Also not the constructors; read the documentation to see how they work) The object you are trying to convert naturally has to give you something that can be transformed into a double.
Finally, keep in mind that Double instances are immutable -- once created you can't change them.