public static void main(String[] args) {
try{
List list1 =new ArrayList<String>();
list1.get(1);
}catch(Exception e){
e.printStackTrace();
}
try{
List list2 =new ArrayList<String>();
list2.add("qweq");
System.out.println(list2.get(0));
}catch(Exception e){
e.printStackTrace();
}
}
}
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
qweq
at java.util.ArrayList.get(ArrayList.java:429)
at com.fastech.monitor_controller.test.AlarmTest.main(AlarmTest.java:205)
总结:异常捕捉不会影响后面代码的执行