convert Array To String With Comma - Android java.lang

Android examples for java.lang:String Join

Description

convert Array To String With Comma

Demo Code


public class Main{

    public static String convertArrayToStringWithComma(final Object[] array) {
        if (array == null) {
            return null;
        } else {//from   w w w  .  ja va  2  s .c  o  m
            StringBuilder sb = new StringBuilder();
            boolean first = true;
            for (int i = 0; i < array.length; i++) {
                if (!first) {
                    sb.append(',');
                }
                sb.append(array[i].toString());
                first = false;
            }
            return sb.toString();
        }
    }

}

Related Tutorials