单线程情况下
java
Java先打印出现异常的位置,再打印调用的位置。
public class TestExp {
public static void main(String[] args) {
try {
test1();
}catch (Exception e){
e.printStackTrace();
}
}
private static void test1() throws IndexOutOfBoundsException{
test2();
}
private static void test2() {
int i =1;
i= i/0;
}
}
python
python 先打印调用位置,再打印异常发生位置
if __name__ == '__main__':
def test():
test1()
a = 1/0
def test1():
a=[1,2]
a[2]
test()