java - resource leak 'Nommy' is never closed error -
i'm new java please explain in full i'm going wrong thank you.
import java.util.scanner; class apples { public static void main (string args[]){ scanner nommy = new scanner (system.in); system.out.println (nommy.nextline()); } }
you should close
scanner after using it. otherwise, you'll warning compiler.
the simplest way add nommy.close()
after last statement.
you should, however, call in finally
block or using try
statement: see https://stackoverflow.com/a/15613676/1547337
Comments
Post a Comment