So how can I generate a bunch of random numbers (i.e 0-10 and generate 5 numbers that are not duplicates of eachother)
Asked
Active
Viewed 37 times
0
-
I dont want to use lists though. – mobinblack Jul 07 '16 at 18:01
-
3Specify that in the question. And also why not? – Dando18 Jul 07 '16 at 18:02
-
get the idea .then apply to your case – Madhawa Priyashantha Jul 07 '16 at 18:02
-
Do they have to be integers? How do you expect to avoid duplicates if you don't keep track of previous numbers? – Checkmate Jul 07 '16 at 18:02
-
I dont really understand them very well, im new to java – mobinblack Jul 07 '16 at 18:02
-
1Well, this is a good time to learn about them, then. A list is a pretty fundamental data structure, and you're going to have to learn about them at some point, so why not now? – azurefrog Jul 07 '16 at 18:04
-
1They're the simplest way to do what you've asked. Anyway, they're a crucially fundamental data structure (in Java and generally in programming), so you'll have to learn them at some point. No time like the present. – yshavit Jul 07 '16 at 18:04
-
Try looking [here](http://www.tutorialspoint.com/java/java_set_interface.htm) and [here](https://docs.oracle.com/javase/tutorial/collections/interfaces/set.html) for ideas/tutorials on sets in java. After you've got a handle on sets, go to [this SO question](https://docs.oracle.com/javase/tutorial/collections/interfaces/set.html) to answer your question. – Dando18 Jul 07 '16 at 18:06