• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need an auto generation logic

 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I need a random sequence generation logic. The sequence can be in the format
(2 alphabets with 1 digit) * n times
for eg :
RT2YU4JK7
PO6HJ2KA9RW3

Any pointers to help me in generating such a kind of sequence in java?

Thanks,
Neelima
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it always "letter letter digit", or can the digit also appear elsewhere? If it is the former then it's quite easy, considering that letters are chars and chars can be treated as ints. Math.random() or java.util.Random can then help:
The digit can be generated similarly except without the last step: Use a StringBuilder to add these all together, then at the end call toString().

Now, if the digit can appear anywhere then it's a bit harder but I'm sure you'll be able to work it out using my example code.
 
Neelima Mohan
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a bunch!
yes the sequence is specific to what I wrote...its only in <letter letter digit> form.
I will just work it out and see.
Your input has been very helpful

Thanks,
Neelima
 
Rob Spoor
Sheriff
Pie
Posts: 20665
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic