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

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -