java - throw error out of the program -
inside code have several throw statements: throws ioexception
, urisyntaxexception
, interruptedexception
etc.). every time there errors, program stops running , exits. how can catch errors without closing program?
you need implement try-catch
block. imagine have method throws exception:
public void somemethod() throws exception { throw new exception(); }
to call method , handle exception, might this:
try { somemethod(); } catch (exception e) { // handle exception here }
Comments
Post a Comment