Java Utililty Methods Array Print

List of utility methods to do Array Print

Description

The list of methods to do Array Print are organized into topic(s).

Method

voidprintArray(T[] array)
print Array
int len = array.length;
System.out.print("[");
for (int i = 0; i < len; i++) {
    if (i != len - 1) {
        System.out.print(array[i] + ", ");
    } else {
        System.out.println(array[i] + "]");
voidprintArray(T[] array)
print Array
printArray(array, 0, array.length);
StringprintArrayElements(T[] array)
print Array Elements
if (array == null) {
    return "null";
if (array.length == 0) {
    return "[]";
StringBuilder out = new StringBuilder();
out.append('[');
...
voidprintArrayFrom(int[] array, int start)
print Array From
if (start >= array.length) {
    System.out.println("[]");
    return;
System.out.print("[");
for (int i = start; i < array.length; i++) {
    System.out.print(array[i]);
    if (i != array.length - 1) {
...
voidprintArrayInfo(int[] array)
print Array Info
try {
    System.out.println("The array lenght is: " + array.length);
    System.out.println("Some text!!!!!!!!!!!!");
    System.out.println("The third element is: " + array[2]);
} catch (NullPointerException e) {
    System.out.println("The array must not be null!");
} catch (ArrayIndexOutOfBoundsException e) {
    System.out.println("The array must has at least 3 elements");
...
voidprintArrayNoSpaces(int[] nums)
print Array No Spaces
for (int i : nums) {
    System.out.print(i + "");
System.out.println();
voidprintArrayRec(int[] workArray, int idx)
print Array Rec
if (idx < 0 || idx >= workArray.length)
    return;
System.out.println(workArray[idx]);
printArrayRec(workArray, idx - 1);
StringprintArrayToString(Object[] array)
Print an Object ArrayHelper to a String.
if (array == null)
    return "null";
StringBuffer buffer = new StringBuffer();
buffer.append('{');
for (int i = 0; i < array.length; i++) {
    if (i > 0)
        buffer.append(',');
    buffer.append(array[i]);
...
voidprintErrInvocationString(String cls, String[] args)
print Err Invocation String
System.err.println(toInvocationString(cls, args));
voidprintfirstBytes(String comment, byte[] input)
printfirst Bytes
System.out.println("\n" + comment);
for (int i = 0; i < 32; i++) {
    if (i > 0 && i % 32 == 0)
        System.out.println("");
    System.out.print(" " + input[i]);
System.out.println("");