//创建对象
StringBuilder sb = new StringBuilder("abc");
//添加数据
sb.append("def");
sb.append("ghi");
sb.append("jkl");
System.out.println(sb);
//反转
StringBuilder reverse = sb.reverse();
System.out.println(reverse);
//获取长度
int length = sb.length();
System.out.println(length);
//把StringBuilder变回字符串
String string = sb.toString();
System.out.println(string);
StringBuilder方法基本操作
最新推荐文章于 2024-05-25 15:56:30 发布