0

My java program, with the section in question shown below, seems to be stuck on the if("".equals) line. The while loop keeps continuing, though NEITHER of the options in the if statement end up running. So, instead of printing out the new data (under the else) or printing out the information (under the default if), it simply keeps asking for new input.

        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;
            }
        }
4

1 回答 1

8

您的while语句后面有一个分号,Java 会将其视为while循环的整个主体,从而导致无限循环。然后它永远不会到达它下面的大括号中的块。

删除分号,因此大括号中的预期块实际上是while循环块。

于 2013-08-29T18:16:47.927 回答