package com.lovcoding.day06;

import java.util.Arrays;

public class TestArr03_Revers_3 {
    //方式1
    public static void main(String[] args) {
        //toCharArray 返回字符数组
        String str = "helloworld";

        //获取字符数组
        char[] chars = str.toCharArray();

        //反转
        for (int i = 0; i < chars.length/2; i++) {
            char temp = chars[i];
            chars[i] = chars[chars.length-1-i];
            chars[chars.length-1-i] = temp;
        }

        System.out.println(Arrays.toString(chars));
    }
}
