7-dimensional vector Java

did I build a 7 dimensional vector in this way?

Yes you have. A vector is a way of storing a magnitude and direction, which is done by correctly assigning the value and sign of each double. A vector in 2-space would require two values, and a vector in 7-space would require 7 values, which you have.

should I somehow work with arrays for this problem like declaring an array;

You can, but you don’t need a multi-dimensional array. To store a single vector in a 7-space, you just need an array of length 7:

double[] data = new double[7]; // store a 7D vector

You could then modify your existing code, replacing x with data[0], y with data[1] and so on.

Leave a Comment