java - Should utilites like the Scanner class be closed before application exit? -


this simple question, i'm curious if standard close things scanner before application exits.

for example, if want scanner searching next input in application- if application closed should close scanner object before exiting application?

you should try clean resources go. when done them, close them (except system.in unless know won't used again)

in case of shutdown, can ignored, in general shouldn't assume program shutdown, , using try-with-resources better option.

try (scanner in = .....) {    // use "in" } // might add code here later. 

in short, don't need worry in case, best practice clean go.


Comments

Popular posts from this blog

bash - How do you programmatically add a bats test? -

Unable to open serial port using Putty to bluetooth device on windows 7 64 bit -

java - Getting exception in JDBC thin driver -