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 6 of 6

Thread: Random variable order.

  1. #1
    Junior Member
    Join Date
    Jan 2012
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Random variable order.

    I just cant figure out the logic here

    I need my array indexes to be printed in a random order.
    I think there must be a random generator limited by 3 (I have three indexes) wich would be written down into another array.
    But how do i get them in the order based on that? And it might generate the same numbers like : 3 3 1 or 2 3 2.

    Please help me with the logic.


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Random variable order.

    Which part of this are you having trouble with? Check out the Math.random() method and the Random class api. Create an SSCCE that demonstrates exactly what you've tried and where you're stuck, and we'll go from there.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Junior Member
    Join Date
    Jan 2012
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Random variable order.

    I am a beginer and what i am makeing is a consol app(for now). And what is Math.random()?
    Last edited by Alex555; January 30th, 2012 at 09:57 AM.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Random variable order.

    The API is your best friend: Java Platform SE 6
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Junior Member
    Join Date
    Jan 2012
    Posts
    18
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Random variable order.

    I am not asking for help with the programming. Just the logic. All I need is help with the random variable print order. I have the random method setup and the array also

  6. #6
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Random variable order.

    Quote Originally Posted by Alex555 View Post
    I am not asking for help with the programming. Just the logic. All I need is help with the random variable print order. I have the random method setup and the array also
    Which part of this are you having trouble with? Check out the Math.random() method and the Random class api. Create an SSCCE that demonstrates exactly what you've tried and where you're stuck, and we'll go from there.
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

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. Replies: 5
    Last Post: November 16th, 2011, 11:22 AM
  3. RPN Help Please! (Order of Operations)
    By yuvalb in forum What's Wrong With My Code?
    Replies: 6
    Last Post: September 30th, 2011, 10:53 AM
  4. Stack Order?
    By TimW in forum AWT / Java Swing
    Replies: 2
    Last Post: September 19th, 2009, 07:33 AM
  5. Generation of random number using random class
    By JavaPF in forum Java Code Snippets and Tutorials
    Replies: 0
    Last Post: April 16th, 2009, 06:10 AM

Tags for this Thread