### Question:
VectorN extends AVectorN { public VectorN subtract(final IVector vector) { checkDimension(vector.getNumDimensions()); for (int i = 0; i < getNumDimensions(); i++) { data[i] -= vector.get(i); } return this; } private  VectorN(final int dim); private  VectorN(final double... data); private  VectorN(final IVector vector); static VectorN zero(final int dim); static VectorN empty(); static VectorN from(final double... data); static VectorN copy(final IVector vector); static VectorN fromReal(final RealVector rv); void set(final int i, final double value); VectorN add(final IVector vector); VectorN subtract(final IVector vector); VectorN multiply(final double factor); VectorN apply(final Function<Double, Double> function); @Override double x(); @Override double y(); @Override double get(final int i); @Override int getNumDimensions();  }### Answer:
@Test public void testSubtract() { VectorN vec1 = VectorN.from(4, 2, 1); VectorN vec2 = VectorN.from(3, 5, 2); vec1.subtract(vec2); assertEquals(VectorN.from(1, -3, -1), vec1); vec1 = VectorN.from(1, 5, 5); vec2 = VectorN.from(-2, 5, -3); vec1.subtract(vec2); assertEquals(VectorN.from(3, 0, 8), vec1); vec2 = VectorN.from(2.4, -3.1, 3); vec1.subtract(vec2); assertEquals(vec1.x(), 0.6, ACCURACY); assertEquals(vec1.y(), 3.1, ACCURACY); }