Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kaspernielsen/62e4eedffdb395228777925551a45e7f to your computer and use it in GitHub Desktop.
Save kaspernielsen/62e4eedffdb395228777925551a45e7f to your computer and use it in GitHub Desktop.
public static String toString(int[] a) {
int iMax = a.length - 1;
if (iMax == -1)
return "[]";
int size = 2 * a.length;
for (int j = 0; j < a.length; j++) {
size += stringSize(a[j]);
}
if (COMPACT_STRINGS) {
byte[] buf = new byte[size];
buf[0] = '[';
int c = 1;
for (int i = 0; ; i++) {
int e = a[i];
c += stringSize(e);
getChars(e, c, buf);
if (i == iMax) {
buf[size-1] = ']';
return new String(buf, LATIN1);
}
buf[c++] = ',';
buf[c++] = ' ';
}
} else {
//TODO implement
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment