title: Creating a Random Number Generator in Java - Array resetting each time
body: <p>I am trying to create my own Random Number Generator in Java and have been using the Lagged Fibonacci formula. </p>
  
  <p>It works when I want to grab one random number, but when I want to generate multiple random numbers it is just pulling the same random number for all iterations rather than holding on to the new array to generate the next random number. </p>
  
  <pre><code>public class RNumbers {
  
      public static void main(String[] args) {
  
          RandomNumberGenerator rd = new RandomNumberGenerator();
          int number = rd.getNumber();
  
          System.out.println(number);
  
          for (int i = 0; i &lt;= 100; i++) {
              int number2 = rd.getNumber();
              System.out.println(number2);
          }
  
      }
  
  }
  </code></pre>
  
  <pre><code>public class RandomNumberGenerator {
  
      public static int getNumber() {
          long seed = System.currentTimeMillis();     // start seed number for formula
          int length = (int) (Math.log10(seed) + 1);  // number of digits int the seed number
          int j = 3;                                  // will always grab the 3rd value from the seed
          int k = 7;                                  // will always grab the 7th value from the seed
          int mod = 10;                               // will always be the mod number for formula 
          int[] arr = new int[length + 1];            // array for seed numbers
          String stseed = String.valueOf(seed);       // seed to String for adding digits to array    
  
          // Take the seed number and turn it into an array of single digit numbers to mimic a sequence
          for (int i = 0; i &lt;= length - 1; i++) {
              arr[i] = Character.getNumericValue(stseed.charAt(i));
          }   
  
          // calculate random number with inputs
          int number = (arr[length - j] + arr[length - k]) % mod;
  
          // add random number to the end of the array in the temp index
          arr[length] = number;
  
          // update array by shifting all indexes down
          for (int i = 0; i &lt;= length - 1; i++) {
              arr[i] = arr[i + 1];
          }
  
          return number;
      }
  
  }
  </code></pre>