title: Increment through int[] as an int
body: <p>So during a homework assignment I made a method that would increment through an integer array as if it were an integer. So what I mean by that is that the index of the int[] would represent the digits in a number.</p>
  
  <p>for example:</p>
  
  <pre><code>int[] digits;
  digits = new int[4]
  </code></pre>
  
  <p>this would be a 4 digit number. index 0 being the 1000's place, index 1 being the 100's place, index 2 being the 10's place and index 3 being the 1's place.
  So the method I made increments through that array like this:
  0000, 0001, 0002, 0003, 0004, --> 0010, 00011, ----> 9999.</p>
  
  <pre><code>public void increment(){
  
          if(digits[3] &lt;= 8){
              digits[3]++;
          }
          else{
              digits[3] = 0;
              if(digits[2] &lt;= 8){
                  digits[2]++;
              }
              else{
                  digits[2] = 0;;
                  if(digits[1] &lt;= 8){
                      digits[1]++;
                  }
                  else{
                      digits[1] = 0;
                      if(digits[0] &lt;= 8){
                          digits[0]++;
                      }
                      else{
                          digits[0] = 0;
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>My question is how would I go about making a method that does the same thing but the method requires an index to be passed in.</p>
  
  <p>for example:</p>
  
  <pre><code>public void increment(int index){
  
        //increments through index number of digits.
  }
  </code></pre>
  
  <p>So something like this:</p>
  
  <pre><code>increment(7);
  </code></pre>
  
  <p>would yield this: 0000000, 0000001, 0000002, 0000003, --> 0000009, 0000010, 0000011, -----> 9999999.</p>
  
  <p>This is personally for my own satisfaction so any help would be great =)</p>