list ls =new arraylist();
for(string s : ls){
run(s); //一个方法
}
现在运行100遍 ,其中一次运行出异常,中断了,现在怎么写能从中断的程序开始继续运行
剩下的方法
try catch 呀
用try包围这部分代码,然后在catch里continue,让循环继续
public class Demo {
public static void main(String[] args) {
List<String> ls =new ArrayList<String>();
for(String s : ls){
try {
run(s);
}
//如果发生错误
catch (Exception e) {
//把错误打印出来
e.printStackTrace();
//继续执行循环
continue;
}
}
}
private static void run(String s) {
}
}