Java Array to String array2string(Object[] array)

Here you can find the source of array2string(Object[] array)

Description

arraystring

License

BSD License

Declaration

public static String array2string(Object[] array) 

Method Source Code

//package com.java2s;
//License from project: BSD License 

public class Main {
    public static String array2string(Object[] array) {
        StringBuffer sb = new StringBuffer("");
        for (int i = 0; i < array.length - 1; i++) {
            sb.append(array[i].toString());
            sb.append(", ");
        }/*w  w w.  ja  v a2 s  .com*/
        if (array.length > 0)
            sb.append(array[array.length - 1]);
        return sb.toString();
    }

    public static String array2string(int[] array) {
        StringBuffer sb = new StringBuffer("[array: ");
        for (int i = 0; i < array.length - 1; i++) {
            sb.append(new Integer(array[i]).toString());
            sb.append("; ");
        }
        if (array.length > 0)
            sb.append(array[array.length - 1]);
        sb.append("]");
        return sb.toString();
    }

    public static String array2string(char[] array) {
        StringBuffer sb = new StringBuffer("[array: ");
        for (int i = 0; i < array.length - 1; i++) {
            sb.append(new Integer(array[i]).toString());
            sb.append("; ");
        }
        if (array.length > 0)
            sb.append(array[array.length - 1]);
        sb.append("]");
        return sb.toString();
    }
}

Related

  1. array2string(int[] _a)
  2. array2String(int[] paramArrayOfInt)
  3. array2String(long[] array)
  4. array2String(long[] array)
  5. array2String(Object[] a, int size)
  6. array2String(Object[] objs)
  7. array2String(String[] array)
  8. array2String(String[] array)
  9. array2String(String[] category)