PATTERN PRINTING JAVA
Java code for printing a right-angled pattern using asterisks
SOURCE CODE:
Explanation:
- This code defines a class called
RightAngledPatternwith a singlemainmethod that will be executed when the program is run. - The first line of the
mainmethod creates a variable calledrowsand assigns it a value of 5. This variable will control the number of rows in the pattern. - The next line starts a
forloop that will iterate over each row in the pattern. The loop runs as long asiis less than or equal torows. In each iteration of the loop,iis incremented by 1. - Inside the outer loop, there's another
forloop that will iterate over each asterisk in the current row. The loop runs as long asjis less than or equal toi. In each iteration of the loop,jis incremented by 1. - Inside the inner loop, there's a call to
System.out.print()which prints an asterisk followed by a space, without moving to the next line. - After the inner loop has finished printing all the asterisks for the current row, there's a call to
System.out.println()which moves the cursor to the next line.
When you run the code, the output will be:
Thanks for readingsend the feedbacks after reading.
Please support!
Please support!


Comments
Post a Comment