【发布时间】:2013-08-29 18:14:47
【问题描述】:
我的 java 程序,以及下面显示的部分,似乎卡在 if("".equals) 行。虽然 if 语句中的选项都没有运行,但 while 循环继续继续。因此,它不是打印出新数据(在 else 下)或打印出信息(在默认 if 下),而是不断要求新的输入。
System.out.println("Type in government type. Enter '?' and click enter for list of gov types.");
while(playerSelection==false);
{
input = fileinput.nextLine();
if("?".equals(input))
{
System.out.println("despotic_monarchy, administrative_monarchy, constitutional_monarchy, despotic_monarchy, enlightened_despotism, feudal_monarchy, revolutionary_empire\n"+
"administrative_republic, beauracratic_despotism, constitutional_republic, republican_dictatorship, merchant_republic, noble_republic, revolutionary_republic\n"+
"papal_government\n"+
"steppe_horde, tribal_democracy, tribal_despotism, tribal_federation");
}
else
{
fileLines[lGov[nationSelected]] = " " + input;
System.out.println(fileLines[lGov[nationSelected]]);
playerSelection=true;
}
}
【问题讨论】:
标签: java string if-statement equals