Java Program to Print Pyramid Pattern of Numbers

number pyramid

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class NumberPyramid
{
    public static void main(String[] args) throws NumberFormatException, IOException
    {
        System.out.print("How many rows You want in your Pyramid:");
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int noOfRows = Integer.parseInt(br.readLine());
        int rowCount = 1;
   
        for (int i = noOfRows; i > 0; i--)
        {
            //Printing i * 2 spaces at the beginning of each row
            for (int j = 1; j <= i * 2; j++)
            {
                System.out.print(" ");
            }
 
            //Printing j value where j value will be 1 to rowcount and add space after every number
            for (int j = 1; j <= rowCount; j++)
            {
                System.out.print(j+" ");
            }
            
            //Printing j value where j value will be rowcount-1 to 1 and add space after every number
            for (int j = rowCount-1; j >= 1; j--)
            {
                System.out.print(j+" ");
            }
 
           //Go to next line after every row
            System.out.println(); 
            rowCount++;
        }
    }
}