Java Array Output printArray(T[] array)

Here you can find the source of printArray(T[] array)

Description

print Array

License

Open Source License

Declaration

public static <T> String printArray(T[] array) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static <T> String printArray(T[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);/* w w  w  . j  av  a  2  s  .c om*/
        return builder.toString();
    }

    public static <T> String printArray(T[] array, String message) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        builder.append(message);
        return builder.toString();
    }

    public static String printArray(int[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(long[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(float[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(double[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(char[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(byte[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(short[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }

    public static String printArray(boolean[] array) {
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < array.length; i++)
            builder.append(array[i]);
        return builder.toString();
    }
}

Related

  1. printArray(Object[] arry, String specialText)
  2. printArray(Object[] data)
  3. printArray(Object[] in)
  4. printArray(String lt, String[] arr, String rt)
  5. printArray(String name, int[] array)
  6. printArrayOfUnknownObjectsOnePerLine(Object[] array)