MCPcopy
hub / github.com/google/guava / toString

Method toString

guava/src/com/google/common/collect/Iterators.java:290–301  ·  view source on GitHub ↗

Returns a string representation of {@code iterator}, with the format {@code [e1, e2, ..., en]}. The iterator will be left exhausted: its {@code hasNext()} method will return {@code false}.

(Iterator<?> iterator)

Source from the content-addressed store, hash-verified

288 * The iterator will be left exhausted: its {@code hasNext()} method will return {@code false}.
289 */
290 public static String toString(Iterator<?> iterator) {
291 StringBuilder sb = new StringBuilder().append('[');
292 boolean first = true;
293 while (iterator.hasNext()) {
294 if (!first) {
295 sb.append(", ");
296 }
297 first = false;
298 sb.append(iterator.next());
299 }
300 return sb.append(']').toString();
301 }
302
303 /**
304 * Returns the single element contained in {@code iterator}.

Callers 4

toStringMethod · 0.95
testToStringMethod · 0.95
testToStringWithNullMethod · 0.95

Calls 4

nextMethod · 0.65
toStringMethod · 0.65
appendMethod · 0.45
hasNextMethod · 0.45

Tested by 3

testToStringMethod · 0.76
testToStringWithNullMethod · 0.76