diff --git a/classpath/java/util/Arrays.java b/classpath/java/util/Arrays.java index 689a352089..786ab091f3 100644 --- a/classpath/java/util/Arrays.java +++ b/classpath/java/util/Arrays.java @@ -17,6 +17,23 @@ public class Arrays { return asList(a).toString(); } + public static String toString(boolean[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + public static String toString(byte[] a) { if (a == null) { return "null"; @@ -34,6 +51,91 @@ public class Arrays { } } + public static String toString(short[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + + public static String toString(int[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + + public static String toString(long[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + + public static String toString(float[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + + public static String toString(double[] a) { + if (a == null) { + return "null"; + } else { + StringBuilder sb = new StringBuilder(); + sb.append("["); + for (int i = 0; i < a.length; ++i) { + sb.append(String.valueOf(a[i])); + if (i + 1 != a.length) { + sb.append(", "); + } + } + sb.append("]"); + return sb.toString(); + } + } + private static boolean equal(Object a, Object b) { return (a == null && b == null) || (a != null && a.equals(b)); }