Error returning vector in a method

1

I can not return vector predictions, Android Studio is not accepting. (incompatible Types)

public double MediaMovelSimples(double[] valores) {

    int i;
    int j;

    double[] previsoes = new double[valores.length - 3];

    int parametro = 0;

    for (i = 0; i < valores.length - 3; i++) {

        for (j = parametro; j < parametro + 3; j++) {

            previsoes[i] += valores[j];
        }
        parametro+=1;
    }
    return previsoes;
}
    
asked by anonymous 14.11.2017 / 13:34

2 answers

3

The problem is that you are creating a method of type double and it is returning an array of double change

public double MediaMovelSimples(double[] valores) {

for

public double[] MediaMovelSimples(double[] valores) {
    
14.11.2017 / 13:41
1

Here public double MediaMovelSimples(double[] valores) you declare and here double[] previsoes , both statements must be the same. That's what the error is saying incompatible types.

    
14.11.2017 / 13:43