loops - Java: If variable is empty (from user input); break; else continue the main method -


sorry if silly question looking way break , start iteration of loop if user's input null. here's code:

while(true) {     // users input     scanner input = new scanner(system.in);     system.out.println("enter text:");     string studentinfo = input.nextline();      if (studentinfo == null) {         system.out.println("please enter valid infomation.");         break;     }     continue; } 

after break, want go while(true) , start again there, asking user input again.

thanks guys,

jt

check for:

if (studentinfo.isempty()) {     continue; } 

remove scanner input = new scanner(system.in); declaration inside while loop.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -