gpt4 book ai didi

java - 为什么我的 toString() 打印的是 toString 类而不是我的覆盖方法?

转载 作者:行者123 更新时间:2023-11-29 10:11:16 28 4
gpt4 key购买 nike

<分区>

Question test = new Question();

useranswer = Integer.parseInt(JOptionPane.showInputDialog(null,
"What is the Result?" + "\n" + test.toString() ));

问题类中的 toString

public String toSting() {
return "" + firstNum + " " + operator + " " + secondNum + " = ";
}

为什么我在调用 toString 时得到的是“getClass().getName() + '@' + Integer.toHexString(hashCode())”格式,而不是我在问题类中覆盖的 toString()?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com