我怎样才能将阵列扩展或缩小到另一个阵列?

时间:2014-07-22 04:10:46

标签: java arrays

我怎么能这样做?

public static double[] adjustFrequency(double[] samples, double factor) {
    // samples = {1,2,3,4,5,6}

    //adjustFrequency(samples, 0.5);
    //samples = (1,1,2,2,3,3,4,4,5,5,6,6}

    //adjustFrequency(sample, 0.5);
    //samples = {1,3,5}
}

1 个答案:

答案 0 :(得分:0)

您应该查看Java Array文档,尤其是函数copyOfRange()。这将允许您复制用于收缩或扩展的阵列的某些部分。