I have a piece of Java code, where there are Vectors defined as Vector1, Vector2, Vector3,.....VectorN and oldVector1, oldVector2, oldVector3,...oldVectorN.
I need to write a loop that runs over all of these vectors and computes the scalar products of each combination of Vector"i" with oldVector"j".
Actually I know that the best way would be to replace the individual vectors with one array containing all the vectors and work with the array.
However I'm not allowed to touch the rest of the code and the definition of the Vectors as separate objects need to be kept.
How can I do something like this?
for (i = 1; i < 10; i++) {
for (j = 1 ; i < 10; j++) {
result[i][j] = dotproduct(Vector"i", oldVector"j");
}
}
Basically, is there any way in Javahow to construct the variable name similar like a string, e.g. e.g. "Vector"+i?