将对象封装到stringBuilder中,调用reverse方法进行反转。例如:
// 字符串
String girl = "李燕茹";
// 字符串转StringBuilder
StringBuilder stringBuilder = new StringBuilder(girl);
// 通过StringBuilder的reverse反转
girl = stringBuilder.reverse().toString();
System.out.println(girl);
输出茹燕李