title: 2d Array in Spiral Order
body: <p>I'm trying to fill an array in spiral order. So far, I can print the array in spiral order, but is there a way to modify the array so that i can fill it in spiral order and then just print the array? I'd like it to go in decreasing order like a countdown. Please help!</p>
  
  <pre><code>public class Spiral {
    public static void main(int m, int n) { 
  
      // create m by n array of integers 1 through m*n
      int[][] values = new int[m][n];
      for (int i = 0; i &lt; m; i++)
          for (int j = 0; j &lt; n; j++)
              values[i][j] = 1 + (m*n)*i + j;
  
      // spiral
      for (int i = (m*n)-1, j = 0; i &gt; 0; i--, j++) {
            for (int k = j; k &lt; i; k++) System.out.println(values[j][k]);
            for (int k = j; k &lt; i; k++) System.out.println(values[k][i]);
            for (int k = i; k &gt; j; k--) System.out.println(values[i][k]);
            for (int k = i; k &gt; j; k--) System.out.println(values[k][j]);
      }
    }
  }
  </code></pre>