码迷,mamicode.com
首页 > 编程语言 > 详细

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

时间:2015-05-18 18:50:52      阅读:139      评论:0      收藏:0      [点我收藏+]

标签:

如果是 “字符串数组” 转 “字符串”,只能通过循环,没有其它方法 
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);

转自:

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

标签:

原文地址:http://www.cnblogs.com/SharkBin/p/4512561.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!