Q:

Java patterns program 6

belongs to collection: Java programs to print patterns

0

ava 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 = 4;
    for (int i = 1; i <= 5; 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 7... >>
<< Java patterns program 5)...