hello friends,

i want to generate a 32 digit random number...........pls help me....... its very urgent...........

Thanks in advance.........

Printable View

- 06-13-2008, 12:11 PMjithanRandom number
hello friends,

i want to generate a 32 digit random number...........pls help me....... its very urgent...........

Thanks in advance......... - 06-13-2008, 01:42 PMsukatoa
If i were to do that( in integer),

Since the maximum positive integer in java is (2 power 31)-1,

i may use a next random number of 9 power 15,

Code:`int val = new Random().nextInt(9 power 15);`

store in a temp variable,

Same procedure again, store in another variable,

Convert the two integer values into String, then use the concat method....(I should show first the output to insure that my algorithm is right)

In Long, you can use directly the nextLong(Long val) to generate values.... by filtering the generated value except the requirement,

You can now have your 32 digit random digit number....