数组 + 交换

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.nextLine();
        char[] chars = str.toCharArray();
        for (int i=0,len = chars.length; i<len/2 ;i++) {
            char a = chars[i];
            char b = chars[len-1-i];
            chars[i] = b;
            chars[len-1-i] = a;
        }
        System.out.println(new String(chars));
    }
}