1. 程式人生 > >java陣列轉為以逗號分隔的字串

java陣列轉為以逗號分隔的字串

/**
     * 將陣列轉換成以逗號分隔的字串
     * 
     * @param needChange
     *            需要轉換的陣列
     * @return 以逗號分割的字串
     */
    public static String arrayToStrWithComma(String[] needChange) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < needChange.length; i++) {
            sb.append(needChange[i]);
            if
((i + 1) != needChange.length) { sb.append(","); } } return sb.toString(); }