小编Sya*_*bam的帖子

Java while循环不会中断(我也将条件设置为false)

我做了一些可以滚动五个骰子的东西,直到它变成五种骰子.我将在下面粘贴我的代码,以便您可以看到它.如果五种类型的成功,我已将我的while条件设置为false.在说"滚动......"后没有任何反应.我应该使用.equals()吗?

package omega;

import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;

public class One {

    public static void main(String[] args) throws InterruptedException {
        Random random = new Random();
        Scanner scan = new Scanner(System.in);

        int one = 1+random.nextInt(6);
        int two = 1+random.nextInt(6);
        int three = 1+random.nextInt(6);
        int four = 1+random.nextInt(6);
        int five = 1+random.nextInt(6);

        boolean rolling = true;
        int rollCount = 0;

        System.out.println("====================");
        System.out.println("      Yahtzee!      ");
        System.out.println("====================");
        System.out.println("");


            System.out.println("Type 0 to roll.");
            int roll = scan.nextInt();

            System.out.println("Rolling...");

            while(rolling == true) {
                switch(roll) { …
Run Code Online (Sandbox Code Playgroud)

java infinite-loop while-loop

2
推荐指数
1
解决办法
165
查看次数

标签 统计

infinite-loop ×1

java ×1

while-loop ×1