Here you can find the source of arrayToCommaString(int[] array)
public static String arrayToCommaString(int[] array)
//package com.java2s; /* ArrayUtil.java 1.0 2010-2-2 * /*from www .j a va 2 s. com*/ * Copyright (c) 2010 by Chen Zhiwu * 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(); } public static String toString(Object[] array) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < array.length; i++) { sb.append(array[i]); sb.append(i < array.length - 1 ? "," : ""); } return sb.toString(); } }