0
How to clear the buffer?
4 Answers
+ 1
What buffer you talking about?
0
the console
0
If you want to empty System.in buffer prior to outputing a prompt and reading response for non SoloLearn code, you can test the Scanner with hasNext(). If true, you can read it with next(). Repeating this until false will empty the buffer.
In SoloLearn, it also empties the buffer, but you can't enter any more responses, since all input must be given prior to running the program. Note: it might be enough to read the end of line with nextLine().
0
Every nextZ() has an equivalent hasNextZ() to test to see if the buffer has a Z in it, where Z is things like Boolean, Double, Float, Int, Line, Long, and Short.