Using Scanner to Read Input

Scanner is a nice addition to the Java libraries, largely supplanting tokenizers and String's split() method. It's a very good starting place when deciding how to process input. However, if using a Scanner to obtain input, make sure to not mix next() and nextLine() calls (or to do it very carefully). The reason is that when next() returns the last token on a line, it leaves its input pointer at the end of line character. That means that if it is immediately followed by a nextLine(), an empty line is returned. This empty line may not be what the software expects.

For details, see the API docs:

From here one can go
, jmartens@umbc.edu