implement Arrays.toString()

This commit is contained in:
Joel Dice
2007-08-23 19:57:42 -06:00
parent 009a743aa8
commit d1dbb45d55
2 changed files with 21 additions and 0 deletions

View File

@ -3,6 +3,19 @@ package java.util;
public class Collections {
private Collections() { }
static String toString(List l) {
StringBuilder sb = new StringBuilder();
sb.append("[");
for (Iterator it = l.iterator(); it.hasNext();) {
sb.append(it.next());
if (it.hasNext()) {
sb.append(",");
}
}
sb.append("]");
return sb.toString();
}
static class IteratorEnumeration<T> implements Enumeration<T> {
private final Iterator<T> it;