China Naming Network - Ziwei Dou Shu - Java: randomly select 5 random numbers in 100.
Java: randomly select 5 random numbers in 100.
You have to work hard! This kind of program has to be asked. Please refer to this code! Read more jdk documents, many of which are well packaged.
Import java.util.hashset;
Common class test {
Public static void main (strinargs []) {
HashSet & lt integer & gths = new HashSet< Integer & gt ();
while (true) {
int a =(int)(math . random()* 100);
If (a> =10&; & ampa & lt= 100) {
hs . add(a);
}
if (hs.size() == 5) {
Break;
}
}
system . out . println(hs);
}
Tips: It's not easy to solve the problem personally, and it's even more difficult. Your support is my motivation to continue answering questions. Please adopt it. Thank you.