集册 Java实例教程 数组到逗号分隔字符串

数组到逗号分隔字符串

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

481
数组到逗号分隔字符串


import java.util.List;

import javax.faces.application.FacesMessage;

import javax.faces.context.FacesContext;/**from n o w    j a v a  . c o m**/


public class Main{

    public static void main(String[] argv) throws Exception{

        String[] stringArray = new String[]{"1","abc","level",null,"nowjava.com","asdf 123"};

        System.out.println(arrayToCommaSeparatedString(stringArray));

    }

    public static String arrayToCommaSeparatedString(String[] stringArray) {

        StringBuilder result = new StringBuilder();

        int count = 0;


        for (String value : stringArray) {

            if (count > 0) {

                
展开阅读全文