- package com.heima.string;
- import java.util.Scanner;
- public class Test4 {
- public static void main(String[] args) {
- Scanner sc =new Scanner (System.in);
- System.out.println("请输入一个字符串:");
- String hang = sc.nextLine ();
- char[]arr = hang.toCharArray();
- String s = "";
- for (int i = arr.length-1; i >= 0; i --) {
- s = s + arr[i];
- }
- System.out.println(s);
- }
- }
复制代码 |
|