Quick actions

cmd+k|ctrl+k

Navigation

Languages

Hollow Pyramid

Snippet info

Language

Java

Visibility

public

Author

sibasisrath2000

Created

2025-11-25T18:14:29.816113Z

Updated

2025-11-25T18:14:29.816113Z

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