java数组的倒序输出。

使其变为
a
ba
cba
dcba
…………
怎么才可以做到呢?用for循环可以么?图片

 /* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
    static String[] sz = { "a", "b", "c", "d", "e", "f" /* ... */ };

    static void showTable(int n)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = 0; j <= n - i; j++)
            {
                System.out.print(" ");
            }
            for (int j = i - 1; j >= 0; j--)
            {
                System.out.print(sz[j]);
            }
            System.out.println();
        }
    }
    public static void main (String[] args) throws java.lang.Exception
    {
        // your code goes here
        showTable(5);
    }
}
 String s = "abcde";
String s1 = "";
for (int i = s.lengh() - 1; i >= 0; i--)
s1 += s.charAt(i);
System.out.println(s1);

for (char M = 'Z'; M >= 'A'; M--) {
System.out.print(M);
}

把打印的内容变为
a
ba
cba
dcba
edcba
.………………
这样的。图片

http://ideone.com/J9LhfP

在线输出结果