Number Pattern in Java

  • A+
Category:Languages

I am trying to make a program that outputs
Number Pattern in Java

So far I have done:

public class printPattern {   public static void main(String[] args) {   int a = 6;   int i, j;   int max = 1;   int num;    for(i = 1; i <= a; i++){   num = 1;   System.out.println("0");     for(j = 1; j <= max; j++){     System.out.print(num);     System.out.print(" ");     num++;     }   max++;   }   } } 

But the output I am getting is

Number Pattern in Java

The "0" is there to show the spaces, but I want to remove the entire line which contains the first "0" so that the output starts with a "1". I am unsure what to change. Any help would be much appreciated. Thank You.

 


I suggest adding conditions (if we need to print out delimiters):

   for (int i = 1; i <= a; ++i) {      if (i > 1)        System.out.println();   // more than 1 line, need delimiter (new line)       for (int j = 1; j <= i; ++j) {        if (j > 1)           System.out.print(" "); // more than 1 column, need delimiter (space)         System.out.print(j);      }       } 

Comment

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