random - prevent repetition of the numbers by not use of Collection Shuffle [Java] -


i used random function in code dont know how prevent repetition.also read questions subject dont want use "shuffle".

thanks , clues.

set doesn't allow duplicates

set set = new hashset();  while (set.size() < 20) {     set.add(r.nextint(100)); } 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -