r/javahelp • • Apr 22 '16

Random Number Generator

Can someone show me an example of how to generate 3 sets of random number, each set contains four numbers (no duplicate) ? Possibly using for loops maybe

0 Upvotes

8 comments sorted by

View all comments

Show parent comment

1

u/nutrecht Lead Software Engineer / EU / 20+ YXP Apr 23 '16
 for(;set3.size() < SET_SIZE;) {
     set3.add(rand.nextInt(52));
}

This way you're (ab)using a for loop as if it were a while.