Here you can find the source of arrayToCommaSeparatedString(int[] array)
public static String arrayToCommaSeparatedString(int[] array)
//package com.java2s; //License from project: Apache License public class Main { public static String arrayToCommaSeparatedString(int[] array) { if (array == null) { return null; }// w w w. ja v a2 s . co m StringBuffer result = new StringBuffer(); for (int i = 0; i < array.length; i++) { result.append(array[i] + (i == array.length - 1 ? "" : ", ")); } return result.toString(); } public static String arrayToCommaSeparatedString(String[] array) { if (array == null) { return null; } StringBuffer result = new StringBuffer(); for (int i = 0; i < array.length; i++) { result.append(array[i] + (i == array.length - 1 ? "" : ", ")); } return result.toString(); } }