Carey Brown wrote:Line 24 is VERY BAD. NEVER EVER close a scanner created from System.in.
Knute Snortum wrote:If you close a Scanner object based on System.in, you will not be able to use System.in afterwards.
Tim Holloway wrote:
If you're using System.in as a heterogeneous data source where you only feed a few lines to the scanner and send the remaining input somewhere else (perhaps even a different scanner), then it would be appropriate not to close the Scanner and simply let it drop out of scope, but this isn't a common practice, and it needs to be done with care and reference to the underlying buffer contents.