1.NumberFormatException exception, the writing process does not show errors, is handled by RuntimeException exception
Public class Gty { publicstaticvoid main (string[] args) { int a=integer.parseint ("123e");} }
2. Generate an exception, the following statement does not hold the line
public class Gty {public static void Main (string[] args) { System.out.println ("start"); int A=integer.parseint ("123e"); int B=integer.parseint ("O"); Exception (Exception) System.out.println ("2. Division calculation: "+ (A/b)); An exception is generated and the following statement does not execute System.out.println ("End");} }
Operation Result:
3.1 Try....catch Handling exception: "Catch exception", Sequential execution
//Print out statements are displayed in sequence when abnormal //finally{} code must be executed } System.out.println ("End");}}
Operation Result:
3.2 Try....catch Handling Exception: System comes with Printstacktrace () method to deal with exceptions, the principle of multithreading
//system provided, the display position is uncertain (multithreading principle);} finally {System.out.println ("code that will execute");//finally{} code must execute}SYSTEM.OUT.PRINTLN ("End");}}
Run result (a):
Operation Result (b):
4. How to start multi-threaded
Anonymous methods and anonymous content classes } catch (Interruptedexception e) {//TODO auto-generated catch Blocke.printstacktrace ();} System.out.println ("in Progress");}). Start ();
Java exception (Exception) processing and multithreaded startup