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();
}
}
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter