java中如何将字符数组转换成字符串,以逗号分割

String[] ary = {"abc", "123", "45"}; 
StringBuffer sb = new StringBuffer();
for(int i = 0; i < ary.length; i++)
{ sb. append(ary[i]..trim()+","); } 
String newStr = sb.toString();
System.out.println(newStr.substring(0, str.length() - 1));

你可能感兴趣的:(java基础)