clean the buffer with scanner java code example
Example: java clear bufffer to take next string inpuit
if(!input.hasNext() || !input.hasNextInt()) {
input.next();
continue;
}
int cmd = input.next();
if(!input.hasNext() || !input.hasNextInt()) {
input.next();
continue;
}
int cmd = input.next();