如何将String型变量转换成double,用Double.parseDouble()方法为什么会没效果呢

yearInterestRate=JOptionPane.showInputDialog(null, "请输入年利率:","输入提示!",JOptionPane.QUESTION_MESSAGE);
//将字符型的变量转换成double型
Double.parseDouble(yearInterestRate);
//计算月利率
monthlyInterestRate=yearInterestRate/12;//为什么这一步出错,提示如下
The operator / is undefined for the argument type(s) String, int
怎么解决?
比如我可以改为monthlyInterestRate=Double.parseDouble(yearInterestRate)/12,但感觉不爽,就想不它彻底转换成字符,怎么做

yearInterestRate 他本身还是字符串,double.parseDouble 返回值是一个double类型追问

那怎样把它变成字符串呢

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-10-14
Double.parseDouble(yearInterestRate);
赋值给Double类型的变量追问

我就想把它转换了