【发布时间】:2010-09-24 22:40:02
【问题描述】:
在 Swing 应用程序中,只有在用户输入正确答案后才能继续执行方法。正确答案存储在String 中,用户答案由听众设置为另一个String。所以,代码是
while (!correctAnswer.equals(currentAnswer)) {
// wait for user to click the button with the correct answer typed into the textfield
}
// and then continue
这种方法一切正常还是你会以某种方式重构它?它不会对CPU施加额外的惩罚吗? 这里有点similar question。
【问题讨论】:
标签: java while-loop cpu-cycles