Java Array to String arrayToString(Object[] ary)

Here you can find the source of arrayToString(Object[] ary)

Description

Converts an array of objects to a string, by concatenating them together and separated with comma.

License

Open Source License

Declaration

public static final String arrayToString(Object[] ary) 

Method Source Code

//package com.java2s;

public class Main {
    /** Converts an array of objects to a string, by concatenating them
     * together and separated with comma.
     *//*from ww  w .  j a  v  a2s. c  o m*/
    public static final String arrayToString(Object[] ary) {
        if (ary == null || ary.length == 0)
            return "";

        final StringBuffer sb = new StringBuffer(50);
        for (int j = 0; j < ary.length; ++j) {
            if (j > 0)
                sb.append(',');
            if (ary[j] != null)
                sb.append(ary[j]);
        }
        return sb.toString();
    }
}

Related

  1. arrayToString(Object[] array, String prefix, String suffix, String separator)
  2. arrayToString(Object[] array, String sep)
  3. arrayToString(Object[] array, String separator)
  4. arrayToString(Object[] array, String separator)
  5. arrayToString(Object[] array, String split)
  6. arrayToString(Object[] list)
  7. arrayToString(Object[] objects)
  8. arrayToString(Object[] objects)
  9. arrayToString(Object[] objects)