Number Pattern in java - using for as well as while loop

Опубликовано: 28 Июнь 2026
на канале: Shake Hands with Programming
2,513
51

We'll make a program using nested for loop as well as nested while loop to print the following pattern according to the value of 'n' entered by user:

*
1 *
1 2 1 *
1 2 3 2 1 *
1 2 1 *
1 *
*

We'll learn how to take input from the user using the scanner class present in util package of java.
We get this resultant output when user enters the value of n=3.

The link to my previous video in which I discussed the number pattern logic without stars:
   • Number Pattern in Java - using for loop  

Feel free to post your queries and doubts in the comment section below...Just hope you are able to understand the logic and concept, please give some suggestions for improvement...Thankyou everyone ♡♥♡...!!!