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
Post a Comment