Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    You may not want to call close() the scanner in this case, because it will close System.in and prevent your application from reading from it later on. (Reading later throws error "no line found") Commented Apr 8, 2014 at 19:11
  • Yes, I agree to that, close() should not be use if the intention is to use System.in later in the program. Commented Apr 9, 2014 at 1:25