Star pattern program using Java - Part 1
Hello! Let's learn how to print a Star pattern in Java.
Please follow the below code and get started 💻.
Java Code
filename - Main.java
class Main {
public static void main(String[] args) {
int n = 5; // variable for the number of rows
for(int i=0; i<n; i++) {
for(int j=0; j<=i; j++) {
System.out.print("* ");
}
System.out.println();
}
}
}
That is all! I hope you find this helpful. Thank you for visiting.