java学习日记 StringBuffer类
2021-05-02 10:28
标签:main change color hang class sys new 区别 str 1、与String区别1 String用+连接字符 StringBuffer用append()方法 String不能修改 StringBuffer可修改 运行结果: 2、两种方法将String类转换成StringBuffer类 3、将StringBuffer类转换成String类 java学习日记 StringBuffer类 标签:main change color hang class sys new 区别 str 原文地址:https://www.cnblogs.com/cathycheng/p/13204267.htmlpublic class StringBufferDemo1 {
public static void main(String[] args) {
StringBuffer sbu = new StringBuffer();
sbu.append("Hello").append("World").append("!!!");
System.out.println("修改之前:"+sbu);
System.out.println("修改之后:"+change(sbu));
}
public static StringBuffer change(StringBuffer temp){
return temp.append("jxqwc").append("gaile");
}
}
修改之前:HelloWorld!!!
修改之后:HelloWorld!!!jxqwcgaile
public class StringBufferDemo1 {
public static void main(String[] args) {
StringBuffer sbu = new StringBuffer("Hello");
System.out.println(sbu);
}
}
public class StringBufferDemo1 {
public static void main(String[] args) {
StringBuffer sbu = new StringBuffer();
sbu.append("Hello");
System.out.println(sbu);
}
}
public class StringBufferDemo1 {
public static void main(String[] args) {
StringBuffer sbu = new StringBuffer("Hello");
String str = sbu.toString();
System.out.println(sbu);
}
}
上一篇:python语句整理
下一篇:Java后端总结
文章标题:java学习日记 StringBuffer类
文章链接:http://soscw.com/index.php/essay/81289.html