字符串操作 倒序

版权声明:如需转载,请务必通知! https://blog.csdn.net/qq_39594542/article/details/85156320

public static void main(String[] args) {
String abc = “This is my first book”;
String[] aaa= abc.split(" “);
for (int i = 0; i <aaa.length ; i++) {
System.out.print(aaa[i]+” ");
}

    System.out.println("\n");

    for (int i = aaa.length-1; i >=0 ; i--) {
        System.out.print(aaa[i]+" ");

    }

    System.out.println("\n");
    String d=null;
    for (int i = aaa.length-1; i >=0 ; i--) {
        System.out.print(" ");
        d = aaa[i];
        char[] dd = d.toCharArray();
        for (int j = dd.length - 1; j >= 0; j--) {
            System.out.print(dd[j] + "");
        }

    }
}

猜你喜欢

转载自blog.csdn.net/qq_39594542/article/details/85156320
今日推荐