赞
踩
StringBuilder转String:
StringBuilder sb = new StringBuilder(); sb.append("hello"); String s = sb.toString(); System.out.println(s);
String转StringBuilder:
String s = "hello"; StringBuilder sb = new StringBuilder(s); System.out.println(sb);
使用Stringbuilder进行拼接:
StringBuilder sb = new StringBuilder(); sb.append("hello"); sb.append("bb"); String s = sb.toString(); System.out.println(s);
输出hellobb,append可以嵌套使用:sb.append("hello").append("bb")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。