DoubleVector implements java.io.Serializable { public int numNonZeroEntries() { int count = 0; for (double element : this.doubleArray) { if (Double.compare(element, 0.0) != 0) { count++; } } return count; } DoubleVector();  DoubleVector(double[] toCopy);  DoubleVector(DoubleVector toCopy); double[] getArrayRef(); double[] getArrayCopy(); int numNonZeroEntries(); void setValue(int index, double value); void addToValue(int index, double value); double sumOfValues(); void getSingleLineDescription(StringBuilder out); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }
@Test public void testNumNonZeroEntries() { assertEquals(0, emptyVector.numNonZeroEntries()); assertEquals(3, array5Vector.numNonZeroEntries()); }