Q:

Java patterns program 7

belongs to collection: Java programs to print patterns

0

Java program to print following pattern of series:

    * * * * *
     * * * *
      * * *
       * *
        *    

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

public class PrintPattern {
  public static void main(String args[]) {
    int space = 0;
    for (int i = 5; i >= 1; i--) {
      //print spaces
      for (int j = 1; j <= space; j++)
        System.out.print(" ");

      //print stars
      for (int j = 1; j <= i; j++)
        System.out.print("* ");

      //print new line
      System.out.println();
      space++;

    }
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Java patterns program 8... >>
<< Java patterns program 6...