I’m trying to create a vector object by importing org.apache.commons.math3.geometry.Vector.
Which confuses me is how to make a instance of it.
I have tried this way:
Vector v1 = new Vector(1, 2, 3);
but the ide says ” ‘Vector’ is abstract, cannot be instantiated”
Does anyone know about this class? thanks.
P.S. the (1, 2, 3) I use may be misleading. What I want is a dynamic vector which I can assign its dimension to it.
Try this:
You need a class that implements Vector. The javadocs tell you there are three choices:
Vector1D,Vector2D, andVector3D.Why they created a 1D vector I’ll never know. I usually call those “scalars”.
If you need a larger vector, then use
RealVectorand its subclass,ArrayRealVector.Are you incapable of opening the javadocs and researching on your own? You’ll make faster progress if you do a little thinking on your own.