PATTERN PRINTING JAVA

  Java code for printing a right-angled pattern using asterisks


SOURCE CODE:


Explanation:

  1. This code defines a class called RightAngledPattern with a single main method that will be executed when the program is run.
  2. The first line of the main method creates a variable called rows and assigns it a value of 5. This variable will control the number of rows in the pattern.
  3. The next line starts a for loop that will iterate over each row in the pattern. The loop runs as long as i is less than or equal to rows. In each iteration of the loop, i is incremented by 1.
  4. Inside the outer loop, there's another for loop that will iterate over each asterisk in the current row. The loop runs as long as j is less than or equal to i. In each iteration of the loop, j is incremented by 1.
  5. 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.
  6. 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.

The outer loop continues until all the rows have been printed.

When you run the code, the output will be:

Thanks for reading 
send the feedbacks after reading.
Please support!

Comments

Popular posts from this blog

CSS Button style animation for biggners

Method overloading (java)