@Test public void testToString() { CircularArray<String> a = new CircularArray<>(5); assertEquals("[null, null, null, null, null]", a.toString()); }
public String toString() { Object[] oa = toArray(); Object o; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < oa.length; i++) { o = oa[i]; if (i > 0) { sb.append(", "); } if (o == null) { sb.append("null"); } else { sb.append(o.toString()); } } sb.append("]"); return sb.toString(); }
CircularArray { public String toString() { Object[] oa = toArray(); Object o; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < oa.length; i++) { o = oa[i]; if (i > 0) { sb.append(", "); } if (o == null) { sb.append("null"); } else { sb.append(o.toString()); } } sb.append("]"); return sb.toString(); } }
CircularArray { public String toString() { Object[] oa = toArray(); Object o; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < oa.length; i++) { o = oa[i]; if (i > 0) { sb.append(", "); } if (o == null) { sb.append("null"); } else { sb.append(o.toString()); } } sb.append("]"); return sb.toString(); } CircularArray(int capacity); }
CircularArray { public String toString() { Object[] oa = toArray(); Object o; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < oa.length; i++) { o = oa[i]; if (i > 0) { sb.append(", "); } if (o == null) { sb.append("null"); } else { sb.append(o.toString()); } } sb.append("]"); return sb.toString(); } CircularArray(int capacity); void clear(); boolean isEmpty(); void add(Object obj); int capacity(); boolean contains(T obj); @SuppressWarnings("unchecked") T get(int index); int indexOf(T obj); void remove(T obj); void resize(int newCapacity); int size(); T[] toArray(); String internalRep(); String toString(); }
CircularArray { public String toString() { Object[] oa = toArray(); Object o; StringBuilder sb = new StringBuilder(); sb.append("["); for (int i = 0; i < oa.length; i++) { o = oa[i]; if (i > 0) { sb.append(", "); } if (o == null) { sb.append("null"); } else { sb.append(o.toString()); } } sb.append("]"); return sb.toString(); } CircularArray(int capacity); void clear(); boolean isEmpty(); void add(Object obj); int capacity(); boolean contains(T obj); @SuppressWarnings("unchecked") T get(int index); int indexOf(T obj); void remove(T obj); void resize(int newCapacity); int size(); T[] toArray(); String internalRep(); String toString();  }