java中如何将字符串数组转换成字符串

如果是 “字符串数组” 转 “字符串”,只能通过循环,没有其它方法 
String[] str = {"abc", "bcd", "def"};
StringBuffer sb = new StringBuffer();
for(int i = 0; i < str.length; i++){
sb. append(str[i]);
}
String s = sb.toString();

如果是 “字符数组” 转 “字符串” 可以通过下边的方法
char[] data={'a','b','c'};
String s=new String(data);

猜你喜欢

转载自blog.csdn.net/qq_38617531/article/details/80953130