Question test = new Question();
useranswer = Integer.parseInt(JOptionPane.showInputDialog(null,
"What is the Result?" + "\n" + test.toString()));
我的toString問題類爲什麼我的toString()打印toString類而不是我的重寫方法?
public String toSting() {
return "" + firstNum + " " + operator + " " + secondNum + " = ";
}
爲什麼我收到 「的getClass()。的getName()+ '@' + Integer.toHexString(hashCode()方法)」 我呼籲的toString格式而不是我的覆蓋toString()在我的問題類?
公共字符串toSting(){ \t \t返回 「」 + firstNum + 「」 +運算+ 「」 + secondNum + 「=」; \t} – H22
'toSting()'不同於'toString()'。 –
哇,我很笨。謝謝。 – H22