Loop in java until users press enter button

How do I loop in java until the user presses the enter button and then stops?

Sort of

while(System.in != ""){ do x; } 
+4
source share
1 answer

Try the following:

 while (System.in.available() == 0) { // Do whatever you want } 
+14
source

Source: https://habr.com/ru/post/1442553/


All Articles