Java Array to Delimited String arrayToCommaSeparatedString(int[] array)

Here you can find the source of arrayToCommaSeparatedString(int[] array)

Description

array To Comma Separated String

License

Apache License

Declaration

public static String arrayToCommaSeparatedString(int[] array) 

Method Source Code

//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();
    }
}

Related

  1. arrayAsCommaSeperatedList(String... items)
  2. arrayAsString(final int[] _intArray)
  3. arrayToCommaDelimitedString(Object[] arr)
  4. arrayToCommaDelimitedString(Object[] arr)
  5. arrayToCommaDelimitedString(Object[] strings)
  6. arrayToCommaString(int[] array)
  7. arrayToCommaString(int[] array)
  8. arrayToDelimitedString(Object[] arr, String delim)
  9. arrayToDelimitedString(Object[] arr, String delim)