Nesting a for loop to print seven elements of an array per line
<p>I'm working on a program that inserts the powers of 2, all the way up to 2^2000, to an array and then prints them all out 7 numbers on a line. I've figured everything out so it works but I feel like there's a better and cleaner way of doing this... particularly around the nested for loop area. I use y-- to decrement the main for-loop but I feel like this isn't a great fit.  Code:</p>

<pre><code>public class powers {

   public static void main(String[] args){
      long arr[] = new long[2000];

      for (int x=0; x&lt;2000; x++){
         arr[x] = (long) Math.pow(2, x);
       }


      for (int y=0; y&lt;14;y++) {
         for (int z=0; z&lt;7; z++) {
            System.out.print(arr[y++] + " ");
         }
         y--; // Decrement y by 1 so that it doesn't get double incremented when top for loop interates
         System.out.println(); // Print a blank line after seven numbers have been on a line
      }

      }

}
</code></pre>
