Rhombus Pattern Program In Java Language

 class Test

{
    public static void main(String args[]){
        int n=5;
        for(int i=1; i<=n; i++){
            //Spaces
            for(int j=1; j<=n-i; j++){
                System.out.print(" ");
            }
            for(int j=1; j<=n; j++){
                if(i==1 || j==1 || i==n || j==n){
                 System.out.print("*");
                }
                else{
                     System.out.print(" ");
                }
               
            }
            System.out.println();
        }
    }
}

OUTPUT:


***** * * * * * * *****

Comments

Popular posts from this blog

Write A C Program To Delete A Single Element From An Array

Evolution of Computer Devices