Pages

Java Asterisk Pattern using Loops - Pattern Two

This is another simple application in Java that uses for loops in creating asterisk patterns.


public class PatternTwo {

    public static void main(String[] args) {

        for (int j = 5; j > 0; j--) {

   System.out.println("");

            for (int i = 5; i >= j; i--) {
                System.out.print(" ");
  
            }
for (int q = 0; q < j; q++) {
                System.out.print("*");
            }
        }
        System.out.println("");
    }
}


This is the sample output of the code above.

3 comments:

  1. Copy-Paste done! Thank you!
    by: fermin data jr.

    ReplyDelete
  2. pakyu ka mali yan tinuro mo
    fan of yours LOL

    ReplyDelete