import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); //创建键盘录入对象
System.out.println("请输入一个字符串");
String str = sc.nextLine(); //录入字符串存储在str中
char[] arr = str.toCharArray(); //将字符串转换为字符数组
String s = ""; //
for (int i = arr.length-1;i>=0;i--) { //倒着遍历字符数组
s = s +arr[i]; //拼接成字符串
}
System.out.println(s);
}
}
|
|