A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Java patterns program 8
Q:

Java patterns program 8

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 = 8;
    for (int i = 1; i <= 5; i++) {
      //print first part of the row
      for (int j = 1; j <= i; j++)
        System.out.print("*");

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

      //print second part of the row
      for (int j = 1; j <= i; j++)
        System.out.print("*");

      //print new lint
      System.out.println();
      space = space - 2;
    }
  }
}

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now