package string; public class StringReverse { public static void main(String[] args) { /** * 字符串反转 */ String str = "dlrow,olleh"; String reverse =new StringBuffer(str).reverse().toString(); System.out.println("反转之前的字符串:"+str); System.out.println("反转之后的字符串:"+reverse); } }
输出结果