* * * Testexception.java * December 6, 2017 afternoon 2:37:47 * Copyright 2017 Fosun Financial.
All Rights Reserved.
* Don't ALTER or REMOVE COPYRIGHT notices or this FILE HEADER. * * Please contact Fosun Corporation or visit * www.fosun.com * If you need additional Informatio
N or have any questions.
* @author Flyer * @version 1.0/Package testfuxing; /** * Function Description * @version * @author Flyer December 6, 2017 afternoon 2:37:47 * @since 1.8/public class Te
stexception {static int i = 0;
public static void Main (String args[]) {Testdigui ();
private static void Testdigui () {try {int t = i/0;
catch (Exception e) {//new runtimeexception (e);
if (I < 3) {System.out.println ("before recursion:" + i);
i++; TesTdigui ();
System.out.println ("Recursive:" + i);
} i = 0;
System.out.println ("Final execution:" + i);
}
}
}
The output is:
Before recursion: 0
Before recursion: 1
Before recursion: 2
Last implemented: 0
After recursion: 0
Last implemented: 0
After recursion: 0
Last implemented: 0
After recursion: 0
Last implemented: 0
private static void TestExceptionOrder1 () {
int q[]= {1,0,8,19};
try {
for (int m:q) {
int t = 100/m;
System.out.println ("T:" + t);
}
}
catch (Exception e) {
System.out.println ("Final execution:" + E);
}
}
private static void TestExceptionOrder2 () {
int q[]= {1,0,8,19};
for (int m:q) {
try {
int t = 100/m;
System.out.println ("T:" + t);
}
catch (Exception e) {
E.printstacktrace ();
System.out.println ("Final execution:" + E);
}
}
}
The first function throws an exception and does not follow
t:100
Last implemented: Java.lang.ArithmeticException:/by zero
The second function throws an exception, which does not affect the subsequent execution of the
t:100
Last implemented: Java.lang.ArithmeticException:/by zero
T:12
T:5