點(diǎn)擊提交顯示是對(duì)的,但是為右側(cè)的顯示是報(bào)錯(cuò)??我寫錯(cuò)了么??
public?class?HelloWorld?{ ????public?static?void?main(String[]?args)?{ ???????? double?m?=?78.5; //將基本類型轉(zhuǎn)換為字符串 String?str1?=?Double.toString(m); ???????? System.out.println("m?轉(zhuǎn)換為String型后與整數(shù)20的求和結(jié)果為:?"+(str1+20)); String?str?=?"180.20"; ????//?將字符串轉(zhuǎn)換為基本類型 Double?a?=?Double.valueOf(str); System.out.println("str?轉(zhuǎn)換為double型后與整數(shù)20的求和結(jié)果為:?"+(a+20)); } }
點(diǎn)擊提交顯示是對(duì)的,但是為右側(cè)的顯示是報(bào)錯(cuò)??我寫錯(cuò)了么??還是瀏覽器問(wèn)題??
error: no suitable method found for toString(double)
String str1 = Integer.toString(m); ;
^
method Integer.toString() is not applicable
(actual and formal argument lists differ in length)
method Integer.toString(int) is not applicable
(actual argument double cannot be converted to int by method invocation conversion)
method Integer.toString(int,int) is not applicable
(actual and formal argument lists differ in length)
method Object.toString() is not applicable
(actual and formal argument lists differ in length)
error: cannot find symbol
Double a = Integer.valueof(str); ;
^
symbol: method valueof(String)
location: class Integer
2 errors
2015-12-15
你給的代碼和你給的錯(cuò)誤信息都對(duì)不上的
第一個(gè)錯(cuò)誤是
String str1 = Integer.toString(m); ;
而你的代碼是
String str1 = Double.toString(m);
修改了代碼要關(guān)掉“下一節(jié)”的提示,然后重新提交才會(huì)重新編譯代碼。
2015-11-29
運(yùn)行了一遍你寫的代碼,沒(méi)問(wèn)題啊
2015-09-12
?Double?a?=?Double.valueOf(str); ?應(yīng)該是double ,是基本類型
Double是類
2015-07-30
本身有個(gè)分號(hào),我自己又寫了一個(gè)。原來(lái)是這樣。