### Question:
ArrayListOfFloats implements RandomAccess, Cloneable, Iterable<Float> { public String toString(int n) { StringBuilder s = new StringBuilder(); s.append("["); int sz = size() > n ? n : size; for (int i = 0; i < sz; i++) { s.append(get(i)); if (i < sz - 1) { s.append(", "); } } s.append(size() > n ? String.format(" ... (%d more) ]", size() - n) : "]"); return s.toString(); } ArrayListOfFloats(int initialCapacity);  ArrayListOfFloats();  ArrayListOfFloats(float[] a);  ArrayListOfFloats(int first, int last); void trimToSize(); void ensureCapacity(int minCapacity); int size(); void setSize(int sz); boolean isEmpty(); boolean contains(float n); int indexOf(float n); int lastIndexOf(float n); ArrayListOfFloats clone(); float get(int index); float set(int index, float element); ArrayListOfFloats add(float e); ArrayListOfFloats add(int index, float element); float remove(int index); void clear(); float[] getArray(); Iterator<Float> iterator(); String toString(int n); @Override String toString(); void sort(); ArrayListOfFloats intersection(ArrayListOfFloats other); ArrayListOfFloats merge(ArrayListOfFloats sortedLst); ArrayListOfFloats subList(int start, int end); void addUnique(int[] arr); void shiftLastNToTop(int n); @Override boolean equals(Object obj);  }### Answer:
@Test public void testToString() { int size = 10; Random r = new Random(); ArrayListOfFloats list = new ArrayListOfFloats(); for (int i = 0; i < size; i++) { list.add(r.nextFloat()); } String out = list.toString(); for (int i = 0; i < size; i++) { float v = list.get(i); assertTrue(out.indexOf(new Float(v).toString()) != -1); } for (int i = 0; i < size; i++) { list.add(r.nextFloat()); } out = list.toString(); for (int i = size; i < size + size; i++) { float v = list.get(i); assertTrue(out.indexOf(new Float(v).toString()) == -1); } assertTrue(out.indexOf(size + " more") != -1); }