You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
506 B
18 lines
506 B
package java1113.lesson05;
|
|
|
|
import java.util.HashSet;
|
|
import java.util.Random;
|
|
import java.util.Set;
|
|
public class HashSetRandom1113 {
|
|
public static void main(String[] args) {
|
|
Set<Integer> numbers = new HashSet<>();
|
|
Random random = new Random();
|
|
while (numbers.size() < 10) {
|
|
int randomNumber = 50 + random.nextInt(31);
|
|
numbers.add(randomNumber);
|
|
}
|
|
for (Integer number : numbers) {
|
|
System.out.println(number);
|
|
}
|
|
}
|
|
} |