Java - Write code to Print Z Figure

Description

Write code to Print Z Figure


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

Demo

import java.util.Scanner;


public class Main {
    public static void main(String[] args) {
        int n = 10;

        for (int i = 0; i <n ; i++) {
            System.out.print("*");

        }// w w w.  j a  va2  s .  c o m
        System.out.println();

        for (int i = n-2; i >0 ; i--) {
            for (int j = 0; j <i ; j++) {
                System.out.print(" ");
            }

            System.out.println("*");
        }
        for (int i = 0; i <n ; i++) {
            System.out.print("*");

        }
    }
}

Related Example