package com.snda.sysdev.virtualsys;
/**
* @author chengyongchun
* @date 14-3-21 下午2:54
*/
public class RetryTest {
public static int retryCount = 3;
public static void retry() throws Exception{
int tries = retryCount;
while (true){
tries--;
try{
System.out.println(tries);
System.out.println(tries/0);
break;
}catch (Exception e){
if(tries<1){
throw e;
}
}
}
}
public static void main(String args[]) throws Exception{
RetryTest.retry();
}
}
本文探讨了在Java中使用递归实现异常处理的过程,通过一个具体的实例展示了如何在有限次数内重试操作并捕获异常。
2424

被折叠的 条评论
为什么被折叠?



