当程序运行时,会发生不正常的事件阻止事先设计好的程序的执行。这些事件称为异常。
除非程序设计捕获和处理这个异常,否则当异常抛出时程序自动终止。
try { Action } catch(ExceptionType Parameter) { Handler }
除非输入在try块中,否则就要有throws IOException
try{Action} catch(ExceptionType Parameter){Handler} finally {Handler}
finally块在try...catch...处理之后,总是会被执行!
throw new NegativeAmountException("Bad balance");