【发布时间】:2014-01-17 05:55:16
【问题描述】:
我正在用 netbeans 用 java 制作一个问答游戏。我为我的所有问题制作了一个数组列表,为我的答案制作了另一个数组列表。我将它们都按顺序排列(比如第一是安大略省的首府……而在答案列表中,第一是多伦多。 ..所以他们都匹配)
我这样做是为了让它随机生成一个问题……但现在我必须让它与答案匹配……并检查用户的输入是否与答案匹配。这是我尝试过的,但它不会工作:
String input = inputTextField.getText();
String output = "";
questions = answers -------> Those are the names of my 2 array lists
if (input = answers) {
output = "Congratulations";
}
else if (input != answers) {
output = "You got the question wrong";
}
** 请帮助...我也是初学者,谢谢:)
【问题讨论】:
-
为什么不尝试使用 HashMap。它会比arraylist容易得多。
标签: java string if-statement arraylist