集册 Java实例教程 将整数数组转换为字符串

将整数数组转换为字符串

欢马劈雪     最近更新时间:2020-01-02 10:19:05

433
将整数数组转换为字符串
/*from n o w j a v a . c o m - 时  代  Java*/

//package com.nowjava;


public class Main {


    public final static String toString(Integer[] array, String split) {

        StringBuilder sb = new StringBuilder();

        for (Integer item : array) {

            sb.append(item.toString());

            sb.append(split);

        }

        String ret = sb.toString();

        if (ret.endsWith(split))

            ret = ret.substring(0, ret.length() - split.length());

        return ret;

    }

}