diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index 94efeea5d6..d4813a9cc8 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -3,12 +3,20 @@ package java.util; public class Arrays { private Arrays() { } + public static String toString(Object[] a) { + return asList(a).toString(); + } + private static boolean equal(Object a, Object b) { return (a == null && b == null) || (a != null && a.equals(b)); } public static List asList(final T ... array) { return new List() { + public String toString() { + return Collections.toString(this); + } + public int size() { return array.length; } diff --git a/classpath/java/util/Collections.java b/classpath/java/util/Collections.java index fb5ac3c685..d8eda7f619 100644 --- a/classpath/java/util/Collections.java +++ b/classpath/java/util/Collections.java @@ -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 implements Enumeration { private final Iterator it;