我有这个表达式,例如:
400 2.11 +
我尝试将实数推入堆栈,当我这样做时,它会在这部分代码中显示错误
ch = input.charAt(j);
if (ch >= '0' && ch <= '9' || ch == '.')
temp = temp + ch;
else if (ch == ' ') {
x = Double.parseDouble(temp);
theStack.push(x);
temp = "";
}
else {
...
public void push(double j) {
stackArray[++top] = j;
}
这是消息
Exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1011)
at java.lang.Double.parseDouble(Double.java:540)
at ParsePost.doParse(ParsePost.java:26)
at InfixApp.main(InfixApp.java:21)