我如何并排放置另一个 java 数字三角形

How do i put the other java number triangle side by side

所以我正在尝试我在互联网上找到的这段代码,它可以让我制作数字三角形,代码就像这样

public class StarsAndDraws {

    
    public static void main(String[] args) {
        
        
        for (int i = 0; i <= 4; i++) {
            
            for (int j = 4; j >= 1; j--){
                
                if (j > i){
                    
                    System.out.print(" ");
                    
                } else {
                    
                    System.out.print(i - j + 1);
                }

            }
            System.out.println();
        }
    }
 
}

输出看起来像这样

      1
    1 2
  1 2 3
1 2 3 4

但这是我正在寻找的输出

               1
             1 2
  1        1 2 3
1 2      1 2 3 4

我不知道如何,感谢帮助和解释,因为我也喜欢对其他类型的东西这样做

要先打印 1/ 1 2,还需要为那个循环定义另一个循环。

class Main {
  public static void main(String[] args) {
    for (int i = 1; i <= 4; i++) {
      if (i < 3) {
        System.out.print(" ".repeat(9));
      } else {
        System.out.print(" ".repeat((4 - i) * 2));
        for (int j = 1; j <= i - 2; j ++) {
          System.out.print(j);
          System.out.print(" ");
        }
        System.out.print(" ".repeat(6));
      }
      System.out.print(" ".repeat(2 * (4 - i)));
      for (int j = 1; j <= i; j ++) {
        System.out.print(j);
        System.out.print(" ");
      }
      System.out.println();
    }
  }
}