title: making a 13 digit random number generator in Java
body: <p>a friend of mine at Uni, was wanting to generate a bunch of 13 digit numbers so he can test his sorting algorithms on, but was doing it a very long way around, so i've tried to use the following code to generate a settable number of 13 digit numbers.</p>
  
  <pre><code>public class random {
  
  public static void main(String[] args) {
  
      long intArray[] = new long[20]; // to generate more than 20 random numbers increase this and the 'i &lt; 20' to the same number ie. 75 
  
      for(int i = 0; i &lt; 20; i++) { // here
          intArray[i] = numbGen();            
      }
  
      for(int j = 0; j &lt; intArray.length; j++) {
          System.out.println(intArray[j]);
      }
  
  }
  
  public static long numbGen() {
  
      long numb = (long)(Math.random() * 10000000 * 1000000); // had to use this as int's are to small for a 13 digit number.
  
      return numb;
  }
  }
  </code></pre>
  
  <p>my issue is now sometimes it will generate a couple of 12 digit numbers in the group of 20 and i want to find a way not to add the number to the array if it is not 13 digits. I've tried if statement but getting stuck on not being able to determine the length (individual characters) of the Long.</p>
  
  <p>Thanks in Advance.</p>