解题思路:
利用StringBuffer类的reverse()方法,简单方便
注意事项:
定义一个String类,转化为StringBuffer类,然后使用reverse()反转字符串。
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
String s=sc.nextLine();
String str=new StringBuffer(s).reverse().toString();
System.out.println(str);
}
}
0.0分
0 人评分