Stop scanner from reading user input java?

前端 未结 4 658
走了就别回头了
走了就别回头了 2021-01-15 14:35

I am trying to write this method, which keeps reading from the user, until the word \"exit\" is inputted. I tried with a break and for loop; it didn\'t work. I was trying wi

4条回答
  •  庸人自扰
    2021-01-15 15:12

    Amirs's answer is 100% correct. In addition, use true inside the while loop and, I think it is better to use else... if statement in this case. More readable, thats why :)

提交回复
热议问题