Ale*_*and 3 java code-reuse function operator-overloading
有没有办法在这些函数中重用迭代数组代码:
public static double[] ln(double[] z) {
// returns an array that consists of the natural logarithm of the values in array z
int count = 0;
for (double i : z){
z[count] = Math.log(i);
count += 1;
}
return z;
}
public static double[] inverse(double[] z) {
// returns an array that consists of the inverse of the values in array z
int count = 0;
for (double i : z){
z[count] = Math.pow(i,-1);
count += 1;
}
return z;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1834 次 |
| 最近记录: |