【发布时间】:2025-11-29 13:35:01
【问题描述】:
我试图让该方法返回由 for 循环创建的新数组。
import java.util.Arrays;
public class stocks {
public static void main(String[] args) {
double stockV [] = {55.6, 63.2, 68.1, 70.1, 72.4, 73.9, 71.5, 68.3, 67.1, 66.2};
double isOverprices [] = overpriced(stockV);
}
public int [] overpriced(double[] rsiValues)
{
for (int i = 0; i < rsiValues.length; i++)
{
if (rsiValues[i] > 70)
{
rsiValues[i] = 1;
}
else if (rsiValues[i] <= 70)
{
rsiValues[i] = 0;
}
return rsiValues;
}
}
}
【问题讨论】:
标签: java arrays class for-loop methods