Pyramid of numbers in java
<p>I am trying to print a pyramid in java
Looks something like this :-</p>

<pre><code>                    9
                  8 9 8
                7 8 9 8 7
              6 7 8 9 8 7 6
            5 6 7 8 9 8 7 6 5
          4 5 6 7 8 9 8 7 6 5 4 
        3 4 5 6 7 8 9 8 7 6 5 4 3 
      2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 
    1 2 3 4 5 6 7 8 9 8 7 6 5 4 3 2 1 
</code></pre>

<p>I was looking for ways to solve this on the internet and I stumbled across this :</p>

<pre><code>class Pyramid {

  public static void main(String[] args) {

    int x = 7;

    for (int i = 1; i &lt;= x; i++) {

        for (int j = 1; j &lt;= x - i; j++)
            System.out.print("   ");

        for (int k = i; k &gt;= 1; k--)
            System.out.print((k &gt;= 10) ?+ k : "  " + k);

        for (int k = 2; k &lt;=i; k++)
            System.out.print((k &gt;= 10) ?+ k : "  " + k);
        System.out.println();
    }  
  }
}
</code></pre>

<p>Could anyone please help me understand this?
Here' what I've figured out :-
The outer loop increments till 7 at the same time the inner j loop increments upto x - i
which is 6 for the first iteration of the outer loop , then 5 ...and so on ..
So basically the left side of the pyramid is just an inverted triangle of blank spaces.</p>

<p>I am having trouble figuring out what is happening in the other two nested loops and the  the strange looking if - else parts inside the print statements</p>
