递归算法可以+999 超了这个数就报 StackOverflowError(栈溢出异常)如何解决?
public class Test {
//计算的方法
public static int account(int start,int stop)throws Exception{
return (start!=stop) ? start+=(account(start+1,stop)) : start;
}
/**
* @param args
*/
public static void main(String[] args) {
try {
System.out.println(account(1,9999));
} catch (Exception e) {
e.printStackTrace();
}
}
各位大神帮我看一下??解决了立马结贴