Forums Register Login

Randomizer

+Pie Number of slices to send: Send
Hello, I am trying to create a randomizer in java.The Goal is the data from the database get's randomized to its different user, for example, you can say it happens in online tests question sequence is in randomized order to different people giving that test.
Any Suggestion is appreciated.Thanks in advance
+Pie Number of slices to send: Send
Math.random()?
+Pie Number of slices to send: Send
Unless you specifically want a double in the range 0.0 ≤ x < 1.0, I suggest you avoid Math#random. Use the Random class or one of its subtypes, for reasons explained here and in more detail here.For randomising Lists, I suggest you go through the methods of the Collections class.
+Pie Number of slices to send: Send
 

priyanshi bhardwaj wrote: for example, you can say it happens in online tests question sequence is in randomized order to different people giving that test.

specifically for achieving the above goal random class a good option?The solution which you are suggesting is I should fetch my data from the database and pass it through this random class then display it to the user accordingly?  


I am just clarifying this... is there any other option other than this? Thanks
+Pie Number of slices to send: Send
I don't think so, you can either use Math.random() or Random class (better to use this).
+Pie Number of slices to send: Send
...or, as Campbell mentions, if it's a Collection you want to"shuffle" then there's method that will do that for you.
(1 cow) 1
+Pie Number of slices to send: Send
 

is there any other option other than this?


Lots, I should think. But to suggest something else we'd have to know in which way the approaches that have been suggested so far do not meet your requirements.
+Pie Number of slices to send: Send
 

Tim Moores wrote:

is there any other option other than this?


Lots, I should think. But to suggest something else we'd have to know in which way the approaches that have been suggested so far do not meet your requirements.


I was just asking actually I already knew above-suggested approaches but I just wanted to know bit different way of doing the same thing.
+Pie Number of slices to send: Send
If you already know some options, please tell us, to avoid our trying to teach our grandmothers to suck eggs. It is much easier if we know you are looking for ”advanced“ options.
I am a man of mystery. Mostly because of this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 336 times.
Similar Threads
Create a Spell Checker utility using Java
Random numbers
Provided data file and 48-hour rule!
Converting an application to Java (new to Java)
ecom applications
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 05:08:58.