1
我試圖解析String
到Double
和由於變量的限制,我必須以非常奇怪的方式做到這一點。目前我遇到的問題是具有兩個命名相同的功能,但一個需要Double
,另一個需要double
。如何在解析字符串時獲得Double而不是Double?
public class Calculator {
Double x;
public Double x(String x){
//code ommited
x(Double.parseDouble(x.substring(x.lastIndexOf(" ") + 1, x.length())));
//^^ attempting to get this variable to be a Double instead of double
return new Double(x);
}
public Double x(Double x){
//code ommited
return new Double(0);
}
public Double x(double x){
//code ommited
return new Double(0);
}
}
'new Double(String)'會將'String'轉換爲'Double'對象。 – khelwood 2014-11-06 19:50:47
不支持自動換行和解包?傳遞雙精度值應該代替雙精度值 – JClassic 2014-11-06 20:02:10