How to return a vector in another vector in Java?

1

I'm doing a program that applies slope uplift, but the value I need to compare to know if the previous one is better than the next one is a vector double

My method to find the best value returns a double vector:

public double[] método(parâmetros){

   código

   return vetor;

}

What I can not do is assign this vector to another vector:

public void método2(parâmetros){

   double vet2[] = new double[n];

   vet2[]=método(parâmetros);

}

My question is how would I be able to return the vector and pass its values to another vector in another method?

    
asked by anonymous 27.09.2017 / 01:21

2 answers

2

This?

public double[] método(int n) {
    return new double[n];
}

public void método2(int n) {
   double vet2[] = método(n);
}
    
27.09.2017 / 01:25
1

You are trying to do the following:

vet2[]=método(parâmetros);

It's like you're trying to access a null position of vet2.

To associate a new vector with the variable, simply name it, without the brackets:

vet2=método(parâmetros);
    
27.09.2017 / 02:07