我该怎么做才能产生空间,从而使结果不同

How do i make it so that spaces generate so the outcome is different

我希望输出有 9 个空格,然后是一个星号,8 个空格,然后是两个星号,7 个空格和 3 个星号,依此类推,直到底部有 10 个星号。 如何生成空格?

import java.util.Scanner;
public class ThreeDotTwelvea
{
    public static void main(String args[])
    {
        final int max_rows = 1;
        for (int row = 10; row  >= max_rows; row--)
        {
            for (int star = 1; star <= row; star++)
                System.out.print ("*");
            System.out.println();
        }
    }
}

试试这个

public class ThreeDotTwelvea {

    final static int NO_OF_ROWS = 10;

    public static void main(String[] args) {

        for (int i = 0; i < NO_OF_ROWS; i++) {
            for (int j = NO_OF_ROWS - i - 1; j > 0; j--) {
                System.out.print(" ");
            }
            for (int j = 0; j <= i; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }
}

输出