Here :
int numbers = 1000000000 + (int)(r.nextDouble() * 999999999);
r.nextDouble() * 999999999
produces a number with 8 digits.
Additioning 1000000000
that contains 10 digits to a number that contains 8 digits will never produce a number that contains 11 digits.
Besides, 11 digits requires a long
not an int
as Integer.MAX_VALUE
== 2147483647
(10 digits).
To get a 11 digits number, you can do :
long n = 10000000000L + ((long)rnd.nextInt(900000000)*100) + rnd.nextInt(100);
((long)rnd.nextInt(900000000)*100) + rnd.nextInt(100)
returns a number between 0
and 89 999 999 999
.
Additionating this number to 10 000 000 000
will produce a number with 11
digits between 0
and 99 999 999 999
.
For example, try that :
public static long generateID() {
return 10000000000L + ((long)rnd.nextInt(900000000)*100) + rnd.nextInt(100);
}