-
红颜莎娜
当然不可以直接强制转换。不过可以相互转换。从String到StringBuffer: StringBuffer sb = New StringBuffer("abcd");从StringBuffer到String: String str = sb.toString();
-
德玛西亚99
//这是代码,看看是不是你想要的……public class Haha {public static void main(String[] args) {// 这是StringBuffer转成String类型的StringBuffer sb = new StringBuffer();sb.append("wa");sb.append("ha");String shuo = sb.toString();System.out.println(shuo);//这是String转成StringBuffer类型的String ni = "ni";String hao = "hao";StringBuffer miss = new StringBuffer();miss.append(ni);miss.append(hao);System.out.println(miss.toString());}}
-
30秒到达战场
String s="";StringBuffer sb=new StringBuffer();把String装进StringBuffersb.append(s);把StringBuffer转换成StringString s2= sb.toString();