字符串反转使用StringBuilder中的方法
程序员文章站
2024-03-05 11:32:36
...
public class Test8 {
public static void main(String[] args) {
String a = "abc";
StringBuilder sb = new StringBuilder(a);
sb.reverse();//返回一个StringBuilder类型将sb覆盖
System.out.println(sb);//cba
}
}