所以我明天正在为我的考试而学习,其中一部分是完成静态方法.我已经完成了所有,但有一部分令我感到困惑.以为我可能会寻求帮助.
下面的说明,我加粗了令人困惑的部分,并解释为什么在下面.
A.在不使用任何标准Java Math库方法的情况下完成此静态方法的实现.仅在抛出异常时使用"if"语句.
/**
* Computes the series n + n^3 + n^5 + ... n^k.
* k-1 is used if k is even.
* @param n the base of the series
* @param k the bound on the exponent of the last term of the series
* @throw IllegalArgumentException when k is less than 1
*/
public double oddSeries(double n, int k) {
if (k < 1) {
throw new IllegalArgumentException("K is less than 1");
}
double …Run Code Online (Sandbox Code Playgroud)