Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create Random number with 5 digit combined of number and charter

I want to generate the random number like that

  • ADF1845CFT

  • ADF1864ATY

  • ADF18AT65Y

Note: There I FIX the ADF18 I want only take the next 5 digit with number and charter

I am successfully create the 5 digit with number

There is Various solution I am using

  • How to make combined random number matrix

  • Java random number with given length

etc. method

With these method I am create successful random 5 digit numbers.

Any Help Appreciate....

like image 581
Arjun saini Avatar asked Nov 01 '25 02:11

Arjun saini


2 Answers

you can use random UUIDs...

Example:

final String randomCode = UUID.randomUUID().toString();
// or you can play with the len...
final String randomCode2 = UUID.randomUUID().toString().substring(0, 5);
like image 110
ΦXocę 웃 Пepeúpa ツ Avatar answered Nov 02 '25 17:11

ΦXocę 웃 Пepeúpa ツ


You can use apache commons-lang RandomStringUtils.randomAlphanumberic:

"ADF18" + RandomStringUtils.randomAlphanumberic(5);
like image 27
Krzysztof Krasoń Avatar answered Nov 02 '25 17:11

Krzysztof Krasoń