Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: How to returned random number to original number?

1. ## How to returned random number to original number?

Hai guys,

Ok, the example about this problem is, i random the number such as 1234 be 3241. And i want to returned the random number 3241 into 1234 again. can anyone help me?.

Best Regards

2. ## Re: How to returned random number to original number?

So you have randomly ordered sequence of digits and you want to sort them? If so, convert your number into discrete chunks (either a string or some type of an array), then use your favorite sorting method to sort the numbers into order.

For a list of differeng sorting methods: Sorting algorithm - Wikipedia, the free encyclopedia (my personal favorite is insertion sort because of it's simplicity and fairly good performance for small data sets)

3. ## Re: How to returned random number to original number?

Thank you for reply helloworld922

but the randomly not just sequence i can be like "CRTG-GJK1", and i random that string and i want return it into originally. can you give me the solution for this?