public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); pattern(5); } static void pattern(int n) { for (int row = 0; row <2*n ; row++) { int totalColsInRow =row>n? 2*n-row-1:row; for (int col = 0; col < totalColsInRow; col++) { System.out.print("* "); } System.out.println(); } } }