自己写的初始版本

import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
    public static void main(String[] args) {
                Scanner in = new Scanner(System.in);
        String string = in.nextLine();
        int length = string.length();
        StringBuilder stringBuilder = new StringBuilder(string);
        // 注意 hasNext 和 hasNextLine 的区别
        //双指针
        int left = 0;
        int right = length - 1;

        while (left < right) {
            char tmpC = string.charAt(left);
            char rightC = string.charAt(right);
            stringBuilder.setCharAt(left, rightC);
            stringBuilder.setCharAt(right, tmpC);
            left++;
            right--;
        }
        String ans = stringBuilder.toString();
        System.out.println(ans);
    }
}