How do I make my program repeat according to certain circumstances?

后端 未结 3 1554
说谎
说谎 2020-12-04 03:46
import java.util.Scanner;

public class MyFirstGame {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        Syste         


        
3条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-04 04:17

    This will run forever, but it's the idea mentioned in the first comment

        ...
        Scanner scanner = new Scanner(System.in);
        while(true){ // add this after Scanner ... declaration
           ...
            } // end of existing else block
        } // end of while loop, so add this single brace
        ...
    

提交回复
热议问题