Skip to content

Commit 2c3ef86

Browse files
authored
Create Star Pattern in Java
Star Pattern Using Java language
1 parent 7f1df0c commit 2c3ef86

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: Star Pattern in Java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
public class RightTrianglePattern
2+
{
3+
public static void main(String args[])
4+
{
5+
//i for rows and j for columns
6+
//row denotes the number of rows you want to print
7+
int i, j, row=6;
8+
//outer loop for rows
9+
for(i=0; i<row; i++)
10+
{
11+
//inner loop for columns
12+
for(j=0; j<=i; j++)
13+
{
14+
//prints stars
15+
System.out.print("* ");
16+
}
17+
//throws the cursor in a new line after printing each line
18+
System.out.println();
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)