Question: > 
> **Possible Duplicate:**  
> 
> [Java random number with given length](https://stackoverflow.com/questions/5392693/java-random-number-with-given-length) 
> 
> 
> 

I have been trying to generate a 15 digit long number in java but it seems I have failed to do it so far as using:

This is producing a maximum of 10 digits. 

```
  Random random = new Random();
  int rand15Digt = random.nextInt(15);

```

How can I generate it successfully?

Answer: 
To begin with, an `int` can hold numbers between `-2,147,483,648` and `2,147,483,647`.

Use [`Random.nextLong()`](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Random.html#nextLong%28%29)
What about trying `BigInteger`, see this StackOverflow link for more information [Random BigInteger Generation](https://stackoverflow.com/questions/2290057/how-to-generate-a-random-biginteger-value-in-java)