Results 1 to 6 of 6

Thread: Random Class

  1. #1
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Random Class

    Hi,

    How can you go about random generating objects through an arraylist?
    Thanks

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default Re: Random Class

    You can't. You can generate random numbers using the Random class, and you can randomize the contents of an ArrayList, but you can't generate objects with an ArrayList. Can you give us the details of your problem including what you've tried and what's not working?

  3. #3
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Re: Random Class

    Ok. I have a Quiz class, which holds an ArrayList of Question objects (each Question has a name, the type and a uniqueNumber). Im trying to create a Quiz tester to possibly random generate Question objects. So maybe can I random generate the uniqueNumber of each Question object and display them randomly? But I can't get my head around it at all.
    Thanks again

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

  5. #5
    dougie1809 is offline Senior Member
    Join Date
    Nov 2011
    Posts
    116
    Rep Power
    0

    Default Re: Random Class

    Thanks. Works perfectly. Alot more appropriate to use. Thanks again.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Using the random class
    By schmitty514 in forum New To Java
    Replies: 6
    Last Post: 04-26-2010, 04:56 AM
  2. Random class
    By KM88 in forum New To Java
    Replies: 9
    Last Post: 10-27-2009, 09:55 PM
  3. Replies: 14
    Last Post: 10-19-2009, 11:57 AM
  4. Replies: 8
    Last Post: 04-19-2009, 06:50 PM
  5. random numbers without random class`
    By carlos123 in forum New To Java
    Replies: 4
    Last Post: 01-17-2008, 11:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •