欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

字符串反转使用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
	}
}

 

相关标签: 字符串反转