for loop not working:" not a statement"

时间:2015-04-11 21:53:06

标签: java for-loop error-handling

if(fightAnswer == true) {
        System.out.println("Let's do this.\n");

        for(dude.speed >= mob1.speed; mob1.defense > 0;
            mob1.defense = mob1.defense - dude.strength) {

            Scanner inFight = new Scanner(System.in);
            mob1.showAttributes();
            System.out.println("Continue fighting? (y/n)");
            fightChoice = inFight.hasNext();
            System.out.print("\n");
        }
}

我无法编译for循环。我一直在寻找一些解决方案,但我似乎并不完全理解这里的错误。 请指教!! 非常感谢所有人提前。

1 个答案:

答案 0 :(得分:-1)

for (;;(dude.speed>=mob1.speed||mob1.defense>=0) {
...
只要dude.speed大于mob1.speed,或者如果mob1.defense大于0,那么应该使循环运行...是你想要做的吗?