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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: How to returned random number to original number?

  1. #1
    Junior Member
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question 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. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,895
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default 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. #3
    Junior Member
    Join Date
    May 2010
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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?

Similar Threads

  1. Generation of random number using random class
    By JavaPF in forum Java SE API Tutorials
    Replies: 1
    Last Post: December 7th, 2011, 05:46 PM
  2. random number generator
    By java3 in forum Loops & Control Statements
    Replies: 4
    Last Post: February 21st, 2011, 12:00 PM
  3. HELP. Random Number Between
    By Raymond Pittman in forum Java Theory & Questions
    Replies: 3
    Last Post: February 15th, 2011, 09:50 AM
  4. Can a for loop work with random number?
    By humdinger in forum Loops & Control Statements
    Replies: 7
    Last Post: January 10th, 2010, 10:06 PM
  5. [SOLVED] Random number method implementation
    By big_c in forum Java Theory & Questions
    Replies: 2
    Last Post: April 15th, 2009, 01:10 PM