Is there any other way to print number 7 pattern in java

  • A+
Category:Languages

I have created pretty simple code to print number 7 but it looks like very easy one , can any one share other logic idea let me try on my own

my code

public class PatternSeven {      public static void main(String[] args)      {         int num = 4;         for(int i = 0; i<=num;i++)         {             System.out.print("*");         }         System.out.println();             System.out.println("   * ");             System.out.println("  *");             System.out.println(" *");             System.out.println("*");     } } 

output

*****    *    *  * * 

 


Another one,

public static void main(String[] args) {     int num = 10;     for (int i = 0; i <= num; i++) {         System.out.print("*");     }     System.out.println();     for (int i = 0; i <= num - 1; i++) {         for (int j = i; j < num - 1; j++) {             System.out.print(" ");         }         System.out.print("*/n");     } } 

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: