How to declare and instantiate a Double vector?

Asked

Viewed 405 times

0

I’m trying to fill a Double vector with 1’s, but I don’t know how to declare and instantiate the variable.

double betaParcial[] = null;

// 'linha' seria o tamanho do vetor, e pode assumir qualquer numero (ex.: 3 ou 4)
for(int i=0 ; i<linha; i++) { 
    betaParcial[i] = 1.0; // Ocorre o erro
}
  • What does 1’s??

  • Type, vector[5] = { 1,1,1,1,1}

1 answer

3


Try:

double betaParcial[] = new double[linha];
  • Bah, that’s right, thank you.

Browser other questions tagged

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