Tag: Trace ice handles the Exce RGS Ima style method without
Try{will produce an exception code
}catch (Type E of the exception that occurred) {
The method of post-processing of abnormal occurrence
}
Once an exception is present and no exception is handled, the program is interrupted.
public static void Main (string[] args) {
try {
int num = 10/0;
SYSTEM.OUT.PRINTLN (num);
} catch (ArithmeticException e) {
System.out.println ("There's an exception!" ");
}
}
This exception is thrown when an operating condition of an exception occurs. For example, an integer "divided by 0" throws an instance of this class.
public static void Main (string[] args) {try {int num = 10/0; SYSTEM.OUT.PRINTLN (num);} catch (ArithmeticException e) {System.out.println ("there is an exception!") "); System.out.println (E.getmessage ());//Print exception Information System.out.println (E.tostring ());//Print exception type and exception information E.printstacktrace (); /print Exception type and exception information, and print out the wrong location}}
Java exception capture and exception handling