How to interrupt an Infinite Loop

前端 未结 12 1973
自闭症患者
自闭症患者 2021-02-02 10:36

Though I know it\'ll be a bit silly to ask, still I want to inquire more about the technical perspective of it.

A simple example of an infinite loop:

pub         


        
12条回答
  •  無奈伤痛
    2021-02-02 11:08

    Here is what I did:

    while(Exit == false){
        Scanner input = new Scanner(System.in);
        String in = input.next();
    
        switch(in){
            case "FindH": 
                FindHyp hyp = new FindHyp();
                float output = hyp.findhyp();
                System.out.println(output); 
            case "Exit":
                Exit = true;
        break;
    
        }
      }  
    

提交回复
热议问题