stackoverflow异常

Sur*_*rya 2 java stack-overflow exception

public static int ExecuteNonQuery(String procedure, params SqlParameter[] args)
{
    if (args == null) throw new ArgumentNullException("args");
    else
    return ExecuteNonQuery(procedure, new SqlParameter[] { });
}
Run Code Online (Sandbox Code Playgroud)

为什么在调用上面的方法时获取递归函数并抛出StackOverFlow异常.(而参数包含5个值)

Bri*_*new 8

不要混淆一个空数组空数组.您使用空数组再次调用相同的方法,但是必须停止此函数的唯一检查是检查空数组,并抛出异常.你需要这样的东西:

if (args.length == 0) {
   // bail out somehow
}
Run Code Online (Sandbox Code Playgroud)

(在您的空检查之后,以防止NPE)