String[] ary = {"abc", "123", "45"};
方法一:
需要引入Apache Commons组件中的个commons-lang.jar包:
String str1=StringUtils.join(ary, ",");
方法二:
String.format()用法使用
String str2 = String.format("%s,%s,%s", ary);
方法三:
遍历拼接
StringBuffer sb = new StringBuffer();
for(int i = 0; i < ary.length; i++){
sb. append(ary[i]..trim()+",");
}
String newStr = sb.toString();
String str3 =newStr.substring(0, str.length() - 1);