在清单5所示设计示例中,我验证所传递的参数,如果它是无效的,我就提出异常。
In the contrived example shown in Listing 5, I validate the passed argument, and if it is invalid, I raise an exception.
无效的final、非final异常参数的数量:41 (0.21%)。
Number of non-effectively-final, non-final exception parameters: 41 (0.21 percent).
许多时候,只需通过检验参数并抛出特定异常说明提供参数无效的原因就可以实现这一点。
Many times, you can do this simply by verifying arguments and throwing specific exceptions that tell why the supplied arguments are invalid.
应用推荐