First, try, catch, finally common combination
Try { xxx}catch(xxxexception e) { e.printstacktrace ();}
Try { xxx}catch(xxxexception e) { e.printstacktrace ();} finally { System.out.println ("I will output σ (っ°д°;) Our store"), whether or not to throw an exception; }
Try { xxx}catch(aexception e) { e.printstacktrace ();} Catch (bexception e) { e.printstacktrace ();} ... Catch (xxxexception e) { e.printstacktrace ();} finally { System.out.println ("I will output σ (っ°д°;) Our store"), whether or not to throw an exception; }
Try { xxx}finally{ System.out.println ("I will output σ (っ°д°;) Our store", whether or not it is thrown); }
The difference between throw and throws
- Throw: Use inside a method, throw an exception manually
- Throws: Used when declaring a method, declaring an exception that might be thrown.
Java exception--Five keywords (try, catch, finally, throw, throws)