@Test public void toStringTest () { CharQueue q = new CharQueue(1); assertEquals("[]", q.toString()); q.addLast((char) 4); assertEquals(q.toString(), "[" + '\4' + "]"); q.addLast((char) 5); q.addLast((char) 6); q.addLast((char) 7); assertEquals(q.toString(), "[" + '\4' + ", " + '\5' + ", " + '\6' + ", " + '\7' + "]"); }
public String toString () { if (size == 0) { return "[]"; } final char[] values = this.values; final int head = this.head; final int tail = this.tail; StringBuilder sb = new StringBuilder(64); sb.append('['); sb.append(values[head]); for (int i = (head + 1) % values.length; i != tail; i = (i + 1) % values.length) { sb.append(", ").append(values[i]); } sb.append(']'); return sb.toString(); }
CharQueue { public String toString () { if (size == 0) { return "[]"; } final char[] values = this.values; final int head = this.head; final int tail = this.tail; StringBuilder sb = new StringBuilder(64); sb.append('['); sb.append(values[head]); for (int i = (head + 1) % values.length; i != tail; i = (i + 1) % values.length) { sb.append(", ").append(values[i]); } sb.append(']'); return sb.toString(); } }
CharQueue { public String toString () { if (size == 0) { return "[]"; } final char[] values = this.values; final int head = this.head; final int tail = this.tail; StringBuilder sb = new StringBuilder(64); sb.append('['); sb.append(values[head]); for (int i = (head + 1) % values.length; i != tail; i = (i + 1) % values.length) { sb.append(", ").append(values[i]); } sb.append(']'); return sb.toString(); } CharQueue();  CharQueue(int initialSize); }
CharQueue { public String toString () { if (size == 0) { return "[]"; } final char[] values = this.values; final int head = this.head; final int tail = this.tail; StringBuilder sb = new StringBuilder(64); sb.append('['); sb.append(values[head]); for (int i = (head + 1) % values.length; i != tail; i = (i + 1) % values.length) { sb.append(", ").append(values[i]); } sb.append(']'); return sb.toString(); } CharQueue();  CharQueue(int initialSize); void addLast(char object); void addFirst(char object); void ensureCapacity(int additional); char removeFirst(); char removeLast(); int indexOf(char value); boolean removeValue(char value); char removeIndex(int index); boolean notEmpty(); boolean isEmpty(); char first(); char last(); char get(int index); void clear(); Iterator<Character> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); }
CharQueue { public String toString () { if (size == 0) { return "[]"; } final char[] values = this.values; final int head = this.head; final int tail = this.tail; StringBuilder sb = new StringBuilder(64); sb.append('['); sb.append(values[head]); for (int i = (head + 1) % values.length; i != tail; i = (i + 1) % values.length) { sb.append(", ").append(values[i]); } sb.append(']'); return sb.toString(); } CharQueue();  CharQueue(int initialSize); void addLast(char object); void addFirst(char object); void ensureCapacity(int additional); char removeFirst(); char removeLast(); int indexOf(char value); boolean removeValue(char value); char removeIndex(int index); boolean notEmpty(); boolean isEmpty(); char first(); char last(); char get(int index); void clear(); Iterator<Character> iterator(); String toString(); String toString(String separator); int hashCode(); boolean equals(Object o); public int size; }