![]() |
VOOZH | about |
Pattern printing is a common problem used to understand nested loops, recursion and control flow in Java. In this article, we explore multiple Java programs to print pyramid, triangle, number and special patterns using different approaches such as for-loops, while-loops, and recursion.
Using Nested for Loops:
* * * * * * * * * * * * * * *
Iterative Pattern Printing:
Recursive Row and Pattern Printing:
* * * * * * * * * * * * * * *
Using Spaces and Stars:
* * * * * * * * * * * * * * *
* * * * * * * * * * * * * * *
Resetting Number for Each Row:
1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Output:
** *
* * *
* * * *
* * * * *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * * *
* * * * * * * * * * * * *
* * * *
* * * *
* * * *
* * * *