Error returning an Array in a? JAVA method

Asked

Viewed 27 times

1

The output of the algorithm is this: [D@28d93b30. I want you to return double[] predicted responses.

public double[] CalculoPrevisao(double[] valores){

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

    double alfa = 2 / (double)( valores.length + 1);

    System.out.println(alfa);

    int auxiliar = 0;
    double media = 0;

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

            media += valores[j];

        }
        media /= 3;

        previsaoPeriodos[i] = alfa * media + (1 - alfa) *  valores[i+2];

        System.out.println(previsaoPeriodos[i]);


        auxiliar +=1;

        media = 0;
    }

return previsaoPeriodos;    
}
  • The return of the function is a double vector... this output is because it is not printing the values of the vector, thus System.out.println(forecastsPeriodos[i]);, you must be printing so System.out.println(forecastsPeriodos);

  • In that case I’ll have to put the method call inside a loop?

  • This... put on a foreach... for(double value: predicted){System.out.println(value); }

  • Thanks bro!....

  • For nothing my friend!!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.