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

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

Description

array To Comma String

License

Open Source License

Declaration

public static String arrayToCommaString(int[] array) 

Method Source Code

//package com.java2s;
/* ArrayUtil.java 1.0 2010-2-2
 * /*from   w ww .  j av  a 2s . c om*/
 * Copyright (c) 2010 by Brook Tran
 * All rights reserved.
 * 
 * The copyright of this software is own by the authors.
 * You may not use, copy or modify this software, except
 * in accordance with the license agreement you entered into 
 * with the copyright holders. For details see accompanying license
 * terms.
 */

public class Main {
    public static String arrayToCommaString(int[] array) {
        StringBuffer sb = new StringBuffer();
        for (int i = array.length - 1; i >= 0; i--) {
            if (array[i] == 0) {
                continue;
            }
            sb.append(array[i]);
            sb.append(i == 0 ? "" : ",");
        }
        return sb.toString();
    }
}

Related

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