title: Way to automate LOADS of nested for-loops? (Java)
body: <p>I have a 3D integer array of length [9][3][3]. Every element in the array is initialised at a value of 1.</p>
  
  <p>I want the very last element of the array (i.e. [8][2][2]) to cycle through all values 1 through 9. Then I want that same element to cycle through them again, for every time the element before it (i.e. [8][2][1]) increases by 1 up until 9. Likewise THIS element cycles through all values 1-9 for every increase of the previous element [8][2][0]. The only thing I can think if is manually setting up 81 nested for-loops, but this would take forever and is incredibly inefficient. I'm sure there's a better way.</p>
  
  <p>Sorry if I'm not very good at explaining myself. Basically let's suppose this 3D array were output entirely in one line. At first it would look something like this:</p>
  
  <pre><code>111111111111111111111111111111111111111111111111111111111111111111111111111111111
  </code></pre>
  
  <p>Then I want that last digit on the right to repeatedly cycle through 1-9, and every time that happens, the one immediately to the left of it increases by 1. Then when THAT one reaches 9, the one to the left of it increases by 1. And so on. Repeat for all 81 elements of the array.</p>
  
  <p>What's a better way to do this rather than 81 nested for-loops?</p>
  
  <p>I apologise for any inaccuracy of terminology or lack of clarity. I'm self taught and rubbish at explaining myself.</p>