這是我的代碼:我怎麼用「雙重」價值與JOptionPane.showInputDialog
currentSalary = (double)(JOptionPane.showInputDialog(frame, "Enter your current salary", "Current Salary", JOptionPane.PLAIN_MESSAGE, null, null, "Numbers only!"));
raise = currentSalary * .04;
total = currentSalary + raise;
NumberFormat money = NumberFormat.getCurrencyInstance();
System.out.println("Your raise is " + money.format(total));
目前,我需要currentSalary雙重價值,但我不能,因爲JOptionPane中僅持有字符串。在仍然使用對話框的情況下,我該如何去做這件事?任何工作答案表示讚賞。謝謝。
Double.parse()。 – nhouser9
解析方法(對象)未定義爲類型Double是它給我的東西 – dirtydan
https://docs.oracle.com/javase/7/docs/api/java/lang/Double.html#parseDouble(java.lang .String) – nhouser9